How to plot negative values with scatter in different color?

4 visualizaciones (últimos 30 días)
Omar Tekin
Omar Tekin el 19 de Feb. de 2018
Comentada: Suraj Mankulangara el 23 de Feb. de 2018
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 comentario
Suraj Mankulangara
Suraj Mankulangara el 23 de Feb. de 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 ?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by