How to plot negative values with scatter in different color?

조회 수: 4 (최근 30일)
Omar Tekin
Omar Tekin 2018년 2월 19일
댓글: Suraj Mankulangara 2018년 2월 23일
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