Ploting known points and their values
Show older comments
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!
Answers (2)
madhan ravi
on 2 Jan 2019
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
on 2 Jan 2019
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 Comments
Michael Student
on 2 Jan 2019
Walter Roberson
on 2 Jan 2019
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
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!