how to draw a 3d plot with different color?

1 回表示 (過去 30 日間)
farfar
farfar 2018 年 1 月 31 日
コメント済み: Walter Roberson 2018 年 1 月 31 日
Hi
I want to assign different color to the specific values in a 3D plot. for example: I have x=[1;2;4;3] y=[1;2;3;4] z=[0.1;0.2;0.3;0.4]
for z>=0.2 scatter3(x,y,z,'b','.') for z=<0.2 scatter3(x,y,z,'g','.')?
thanks

採用された回答

Rik
Rik 2018 年 1 月 31 日
Logical indexing is your answer:
scatter3(x(z>0.2),y(z>0.2),z(z>0.2),'b.')
hold on
scatter3(x(z=<0.2),y(z=<0.2),z(z=<0.2),'g.')
  4 件のコメント
Rik
Rik 2018 年 1 月 31 日
You could hack a colorbar to do something like that, but it won't be pretty. (set the tick property to 0.2 and use caxis)
Walter Roberson
Walter Roberson 2018 年 1 月 31 日
color = repmat('b', size(z));
color(z<0.2) = 'g';
pointsize = 20;
scatter(x, y, pointsize, color);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurfaces, Volumes, and Polygons についてさらに検索

タグ


Translated by