Change colours of specific points in a scatter plot that has already been plotted?
4 views (last 30 days)
Show older comments
David Haydock
on 17 Aug 2020
Commented: David Haydock
on 17 Aug 2020
I have a dimensionality reduction algorithm that extracts latent variables from a dataset and visualises one latent variable with three subplots. The third of the three subplots is a scatter plot, and I want to change the colours of some of the points in this scatter plot.
I know what the indexes of the points that I want to change the colour of are, but I cannot just plot one set one colour and then another set another colour, because the plots are generated from a 3rd order tensor, and are not just datapoints.
Hence I ask: is it possible for me to change colours the datapoints in the plot, after they have been plotted?
5 Comments
Accepted Answer
Abdolkarim Mohammadi
on 17 Aug 2020
Take a look at gscatter().
2 Comments
Abdolkarim Mohammadi
on 17 Aug 2020
Edited: Abdolkarim Mohammadi
on 17 Aug 2020
You can first extract XData and YData of the figure you want, then create a grouping variable, where, for example, intact points are in group 1 and recolored points are in group 2, then you clear the axes, and draw your own scatter plot using gscatter().
Ax = subplot (3,3, 3);
X = Ax.Children(1).XData;
Y = Ax.Children(1).YData;
Grouping = ones (NumPoints,1);
Grouping (RecoloredPointsIndexes) = 2;
cla;
GscatterHdl = gscatter (X,Y,Grouping);
GscatterHdl(1) = 'b';
GscatterHdl(2) = 'g';
Next you do the same for
Ax = subplot (3,3, 6);
and
Ax = subplot (3,3, 9);
More Answers (0)
See Also
Categories
Find more on Data Distribution 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!