how can i plot this kind of graph?

1 回表示 (過去 30 日間)
Devin
Devin 2017 年 3 月 21 日
コメント済み: Star Strider 2017 年 3 月 22 日
Hi everyone, I need to plot this kind of graph in my paper. Can anyone give me some hints how to plot it by matlab? Thank you very much!

採用された回答

Star Strider
Star Strider 2017 年 3 月 21 日
This will get you started:
N = 10;
[X,Y,Z] = sphere(N-1);
Xr = randi(20, 10, 1);
Yr = randi(20, 10, 1);
Zr = randi(20, 10, 1);
for k1 = 1:N
Xv{k1} = X + Xr(k1);
Yv{k1} = Y + Yr(k1);
Zv{k1} = Z + Zr(k1);
end
figure(1)
surf(Xv{1}, Yv{1}, Zv{1})
hold on
for k1 = 2:N
surf(Xv{k1}, Yv{k1}, Zv{k1})
end
hold off
set(gca, 'Box','on', 'BoxStyle','full', 'XTick',[], 'YTick',[], 'ZTick',[])
grid off
axis equal
This will produce a plot similar to ‘B’. You will have to experiment with the patch function to get the box colors in ‘A’.
See the documentation for the relevant functions for details on how to use them.
  4 件のコメント
Devin
Devin 2017 年 3 月 22 日
Do you know how can I make the sphere color change with data? Thank you!
Star Strider
Star Strider 2017 年 3 月 22 日
I thought they did in the plot in my code. There weren’t many spheres, so the color change wasn’t as obvious as it would be with more.
It’s a bit more obvious in this slightly revised code:
Nf = 10; % Sphere Faces
[X,Y,Z] = sphere(Nf-1);
Ns = 250; % Number Of Spheres
Xr = randi(20, Ns, 1);
Yr = randi(20, Ns, 1);
Zr = randi(20, Ns, 1);
for k1 = 1:Ns
Xv{k1} = X + Xr(k1);
Yv{k1} = Y + Yr(k1);
Zv{k1} = Z + Zr(k1);
end
figure(1)
surf(Xv{1}, Yv{1}, Zv{1})
colormap(jet)
hold on
for k1 = 2:Ns
surf(Xv{k1}, Yv{k1}, Zv{k1})
end
hold off
set(gca, 'Box','on', 'BoxStyle','full', 'XTick',[], 'YTick',[], 'ZTick',[], 'LineWidth',2)
grid off
axis equal

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by