Change colours of specific points in a scatter plot that has already been plotted?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Abdolkarim Mohammadi
2020-8-17
Take a look at gscatter().
2 个评论
Abdolkarim Mohammadi
2020-8-17
编辑:Abdolkarim Mohammadi
2020-8-17
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);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!