Scatter3 with colorbar assigned to z axis

36 ビュー (過去 30 日間)
Nick Turton
Nick Turton 2021 年 7 月 7 日
コメント済み: Nick Turton 2021 年 7 月 7 日
Hi,
I would like to do create a scatter3 plot where the color of the circles is assigned by it's corresponding z axis value. I have tried the following code
load inputmatfile.mat
figure;
cmp = linspace(min(z),max(z),numel(z));
scatter3(x,y,z, [], cmp,'filled'); colorbar;
view(-80,15)
xlabel('x axis'); ylabel('y axis'); zlabel('z axis')
grid on;grid minor
However, this assigns the limits of the colorbar by the z axis but determins the colour of the circles based on the y-axis, which is not what I want.
Is there anyway to force it to choose the colour of the circles based on the z-axis value

採用された回答

KSSV
KSSV 2021 年 7 月 7 日
figure;
cmp = linspace(min(z),max(z),numel(z));
scatter3(x,y,z, [], z,'filled'); colorbar;
view(-80,15)
xlabel('x axis'); ylabel('y axis'); zlabel('z axis')
grid on;grid minor
  1 件のコメント
Nick Turton
Nick Turton 2021 年 7 月 7 日
That worked perfectly, thankyou

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by