MATLAB: How can i plot this kind of graph

graphMATLABplot

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!

Best Answer

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.
Related Question