Multiple surface plots on a single figure

3 次查看(过去 30 天)
I am trying to make several figures with multiple surface plots on each. Not using subplot or anything, just a bunch of different-colored shells overlapping each other on one figure. What I've been trying to work with is:
for c = 1:figum
figure(c)
resolution = 50;
theta = linspace(1.7, 2.6, res);
phi = linspace(-.1, 0.8, res);
[theta, phi] = meshgrid(theta, phi);
hold on
for c = 1:10
%Calculate r values based on model parameters
[x, y, z] = sph2cart(theta, phi, r);
surf(x,y,z,(ones(size(x))*c))
end
hold off
legend('1','2','3','4','5','6','7','8','9','10')
end
But all I'm getting from this is Figure 1 with the tenth surface for the last figure, and then blank figure windows for the higher numbered figures in the loop. Any ideas why it seems to be skipping my hold on commands AND my new figure commands and just overwriting everything on the first figure?
Thanks in advance!

回答(1 个)

Walter Roberson
Walter Roberson 2012-1-30
Perhaps you want figure(c) instead of figure(fignum), since fignum is a constant?
  1 个评论
B K
B K 2012-1-30
Using the constant was an accidental side effect of my condensing two function's worth of material into a quick form to post on here. The real code is advancing in the loop properly.
I tried doing what you suggested, so what I basically do is
for c = 1:fignum
f = figure();
ax = axes('Parent',f);
plotsurface(ax)
end
Where plotsurface then uses
hold on
for c = 1:10
surf(ax, x, y, z, (ones(size(x))*c)
end
hold off
But I'm still getting the same issue, several blank figures and Figure 1 having the shape number 10 in it with nothing else, even though the legend indicates there should be all 10 shapes.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by