plotmatrix - how to change the color according to one variable in data?

조회 수: 5 (최근 30일)
Karolina
Karolina 2015년 11월 26일
답변: Tobias Held 2022년 2월 28일
I have dataset with 5 different variables. I would like to generate plotmatrix where all plots are colored according to the first variable (first variable has values "one" or "two". I used the following code, but all my plots still have the same color.
if Y(:,1) > 1
plotmatrix(Y,'g');
hold on
else plotmatrix(Y,'r');
end
hold off

답변 (3개)

Adam
Adam 2015년 11월 26일
편집: Adam 2015년 11월 26일
The final example of
doc plotmatrix
shows how colour individual plots if that is what you are aiming to do (at least in the help for R2015b and it mentions the notation change for R2014a so I assume it has been there for a few versions).
I haven't followed the steps myself, but one of the graphs shown has a different colour to the rest.
  댓글 수: 3
Karolina
Karolina 2015년 11월 27일
Thank you, but it is not what I am looking for. I do not want to change the color of one graph. I want to color all graphs according to one variable (the first column in my data) which has values 1 or 2, so every graph should be represented by two colors: groups of data which have 1 in one color and group of data which have 2 in another color.
Matthieu Heitz
Matthieu Heitz 2017년 7월 17일
The function 'gplotmatrix()' does this exactly, pass your first column of labels as the 'group' parameter. You need the Statistics and MachineLearning Toolbox though.

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


Stephen23
Stephen23 2017년 7월 17일
plotmatrix(Y(Y(:,1)==1,:),'g');
hold on
plotmatrix(Y(Y(:,1)==2,:),'r');

Tobias Held
Tobias Held 2022년 2월 28일
I was looking for the same function, but with a continuous scale. However, I was not able to find an answer and made a function myself. I am happy to receive feedback :)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by