Ploting known points and their values

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 个)

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
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 个评论

Hey! And thanks!
But what if i waned to use the gscatter? for example 1- 'x' and 2 - 'o' on the graph.
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 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by