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
David Haydock
David Haydock 2020년 8월 17일
I know the indices a priori, but I don't know the values that the datapoints are going to be until after I generate the plot.
Let me show the code to make this a bit clearer:
% M is a special type of array that contains special variables.
% Put simply, it isn't just the datapoints that I want
load('output_last.mat', 'M');
% This is a function from the tensor toolbox, it extracts out the datapoints that
% I want to plot from M.
[info] = viz_ktensor(M, ...
'Plottype', {'bar', 'line', 'scatter'}, ...
'Modetitles', {'neurons', 'time', 'trials'}),...
set(gcf, 'Name', ['estimated factors - fit #' num2str(n)])
The output is this:
I am focusing on the scatter plots on the far right here.
Do you see how I have to put my dataset into this black box called "viz_tensor" in order to get my plots?
So, I want to change the colours of certain datapoints on these scatter plots on the right hand side.
E.g. I know that in the 250 datapoints that I have, that I want 3, 7, 10... etc to all be green. But, because the datapoints come from a model, I don't know the value that they take on until after the plot.
I have the scatter plot, and I have the indices, so all I want to do is change the colours of datapoints on the plot for those specific indices.
David Haydock
David Haydock 2020년 8월 17일
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!

댓글을 달려면 로그인하십시오.

채택된 답변

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020년 8월 17일
Take a look at gscatter().
  댓글 수: 2
David Haydock
David Haydock 2020년 8월 17일
This does look like it would be useful, but I dont know how to use this when I only have my datapoints after I have plotted them. The plots that I get come out of a toolbox that I would have to dig in to the change the scatters that are generated.
I can look at the information inside the generated scatter plot to see what the X and Y data are that are plotted, so how can I use this data inside gscatter?
Abdolkarim Mohammadi
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 CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by