Change colours of specific points in a scatter plot that has already been plotted?

16 views (last 30 days)
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?
David Haydock
David Haydock on 17 Aug 2020
Update: figured it out. The output of the function "info" contains information of X and Y data for the plots so I can use these.
Apologies for the confusing question and thanks all for the help!

Sign in to comment.

Accepted Answer

Abdolkarim Mohammadi
Abdolkarim Mohammadi on 17 Aug 2020
Take a look at gscatter().
Abdolkarim Mohammadi
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;
GscatterHdl = gscatter (X,Y,Grouping);
GscatterHdl(1) = 'b';
GscatterHdl(2) = 'g';
Next you do the same for
Ax = subplot (3,3, 6);
Ax = subplot (3,3, 9);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!