Hello everyone,
I have a matrix full of x1,x2,x3 (cordinates) and y (lables) for each cordinate.
For example y can contain 1 or 2, for '1' values i want to plot 'o' sign and for '2' values i want to plot a 'x' .
Is there a way to do it with a simple plot?
Thank you.
edit:
for example :
x1=[4,6,7,2], x2=[3,6,7,2], x3=[5,2,1,6], y=[1,1,2,2],
that mean thats at the cordiantes 4,3,5 i would see an o and for 7,7,1 i'd see an 'x'.
Thanks again!

댓글 수: 2

madhan ravi
madhan ravi 2019년 1월 2일
upload your data
for example
x1=[4,6,7,2], x2=[3,6,7,2], x3=[5,2,1,6], y=[1,1,2,2]

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

답변 (2개)

madhan ravi
madhan ravi 2019년 1월 2일

0 개 추천

x1=[4,6,7,2], x2=[3,6,7,2], x3=[5,2,1,6], y=[1,1,2,2]
X=[x1;x2;x3];
for i = 1:numel(y)
if y(i)==1
figure
plot(X,'+')
elseif y(i)==2
figure
plot(X,'-')
end
end
Walter Roberson
Walter Roberson 2019년 1월 2일

0 개 추천

The provided tool for this kind of plot is gscatter() . However gscatter does not handle - as a marker.
You should
mask = y==1;
text(x1(mask), x2(mask), x3(mask), '+');
and likewise with y==2 and text '-'

댓글 수: 2

Michael Student
Michael Student 2019년 1월 2일
Hey! And thanks!
But what if i waned to use the gscatter? for example 1- 'x' and 2 - 'o' on the graph.
Walter Roberson
Walter Roberson 2019년 1월 2일
I am left a bit uncertain as to whether your (x1,x2,x3) are together providing X, Y, Z coordinates, or whether you just happen to be doing three separate vectors x1, x2, x3, and for each of them the x coordinate should be 1:length(X) with the y coordinate being X ?
if you are indeed using (X,Y,Z) triples as the points, then I suggest using gscatter3 from https://www.mathworks.com/matlabcentral/fileexchange/61502-gscatter3 -- though I am not convinced that their gscatter3b (for use with statistics toolbox) handles z correctly

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

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

질문:

2019년 1월 2일

댓글:

2019년 1월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by