How to plot negative values with scatter in different color?

4 次查看(过去 30 天)
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 个评论
Suraj Mankulangara
Suraj Mankulangara 2018-2-23
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 ?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by