How can I do a scatter plot with different color and symbols

조회 수: 17 (최근 30일)
Riyadh Muttaleb
Riyadh Muttaleb 2020년 12월 8일
답변: Riyadh Muttaleb 2020년 12월 9일
Hi Everyone,
I want to plot scatter plot with diffrent symboles and color for my posative and negative data,
I have:
X: vector
Y vector
Z:[ -1 2 -3 4] so I made it:
Z1[NaN 2 Nan 4]
z2[-1 NaN -3 NaN]
I used:
scatter(X,Y,[],Z1,'r','filled','d'); hold on;
scatter(X,Y,[],Z2,'b','filled','c')
however it hasn't worked
Any help,
Thanks in advance!
Riyadh

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 12월 8일
X = 0:4;
Y = 5:9;
Z = [ -1 2 -3 4];
ind = Z>=0;
scatter(X(ind),Y(ind),'r','filled','d');
hold on
scatter(X(~ind),Y(~ind),'b','filled','c')
hold off
  댓글 수: 6
Cris LaPierre
Cris LaPierre 2020년 12월 9일
Could you provide you actual code and values?
Riyadh Muttaleb
Riyadh Muttaleb 2020년 12월 9일
I don't know how to attach the code and data, however, assume I have these data.
I want to make color and symble for -ve , +ve and NaN (OR zero something diffrent)
X = 0:6;
Y = 5:11;
Z = [ -1 2 -3 4 NaN NaN];

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

추가 답변 (1개)

Riyadh Muttaleb
Riyadh Muttaleb 2020년 12월 9일
I did it!
thank you so much for your time and help!

카테고리

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