How to plot negative values with scatter in different color?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
What I have are x and y values which I then use to generate z as a peak function. So z is basically a matrix with negative and positive values. What I want to now is to have the negative values in a different color as the positive values.
h=scatter(x,y,z,C);
Does anyone know how to do this?
What I tried before is this: if y>0 h=scatter(x,y,z,'bo'); else y=abs(y); h=scatter(x,y,z,'ro'); end
But this obviously checks the Matrix as a whole and only plots one of the two cases and not every point from the Matrix individually.
1 Kommentar
Suraj Mankulangara
am 23 Feb. 2018
It looks like you are trying to create a 3D scatter plot, in which case you might want to use the scatter3() function
So basically, what you are trying to do is, for the points in matrix y that correspond to negative values, the scatter plot of z should be in one color, and for points in y that are positive, the scatter plot of z should be in another color ?
Antworten (0)
Siehe auch
Kategorien
Mehr zu Scatter Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!