How to make sure the symbol and colour for the Scatter plot
3 views (last 30 days)
Show older comments
I tried to generate a scatter plot based on (:,1) data using this code to groups/cluster the data into 5 cluster
subplot(2,2,3);
gscatter(zz(:,1),y,IDX,'bgm','xo+*.')
hold on
plot(C(:,1),C(:,1),'kx');
grid on;
xlabel('Data point');
ylabel('No of observations');
title ('Scatter plot of average wave energy density for 28 years (1993 to 2020)- after cluster');
legend ('Cluster 1', 'Cluster 2','Cluster 3', 'Cluster 4', 'Cluster 5','Cluster Centroid');
hold off;
But, when i run the code the symbol/colour is not in follow the legend. I want the legend to follow the graph. But the legend is not place orderly as the plot. Also may I know how to change the symbol size.
1 Comment
Dyuman Joshi
on 9 Jan 2023
What do you mean by "orderly sequence"?
The functions will plot according to what the input and the data is.
Answers (1)
Dinesh
on 28 Feb 2023
Hi !
It looks like you want to place the legend right under the graph. You can do that using legend location "lcn" parameter.
Refer this MATLAB documentation to change location of legend on the plot [use southoutside to place it outside the axes].
About the part on how to change the symbol size on scatter plot we can use the size "sz" argument.
Refer this MATLAB documentation to change marker size. [Set marker size to a higher value like 15-20 to notice the change]
0 Comments
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!