how do to plot points in different colors based on their labels in 2D and 3D?
6 views (last 30 days)
Show older comments
Dear experiences...
Im trying to make a plot change its color based on data labels... according to follow: i'm having clustered data points and based on their cluster id (cluster) i need to colored points, so according to my example where clusters =7, i need to plot whole points to 7 colors..
then, i need to plot centroids points also in the same figure... in 2D and 3D in scatter plot, where X,Y and Z columns represent--> my X , Y and Z coordinates of my points,
Point Name X_data Y-Data Z_data class
p1 val val val 1
p2 val val val 2
p3 val val val 3
etc...
pn val val val 7
then for centroids points :
the coordinates of centroids points are in X, Y and Z also
cent_id X Y Z
1 val val val
2 val val val
...
7 val val val
.. So how can i plot these points in dots with different colors for both points and centroids .. and also plot points with labels ( p1, p2...etc) that appear in scatter plot instead of dot.
thanks
0 Comments
Answers (1)
Image Analyst
on 2 Jul 2017
Why can't you use gscatter()?
For text labels, use text():
text(x,y,txt) adds a text description to one or more data points in the current axes using the text specified by txt. To add text to one point, specify x and y as scalars in data units. To add text to multiple points, specify x and y as vectors with equal length.
2 Comments
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!