Two patches in one figure

16 views (last 30 days)
aleksander maz
aleksander maz on 5 Mar 2017
Commented: aleksander maz on 6 Mar 2017
Hi,
please I'm trying to make two patches in one figure, after plotting the first one it disappears and I get the second one 'disk2' only. I've tried 'hold on' but it doesn't work
basically I've this piece of code for plotting
for ii=1:length(y)
set(disk1, 'xdata', xcirc1(:,ii), 'ydata', ycirc1(:,ii), 'zdata', zcirc1(:,ii));
set(disk2, 'xdata', xcirc2(:,ii), 'ydata', ycirc2(:,ii), 'zdata', zcirc2(:,ii));
drawnow
pause(0.01)
end
Any one could please give me suggestion for solving it.
Thank you.
  4 Comments
Star Strider
Star Strider on 5 Mar 2017
How do you calculate the ‘xcirc’, ‘ycirc’, and ‘zirc’ vectors? What are you plotting?
What do you want your plot to show?
aleksander maz
aleksander maz on 6 Mar 2017
Hi star, I'm trying to plot a disk in three dimension. and xcirc, ycirc zcirc; are the matrices for plotting it.

Sign in to comment.

Accepted Answer

Jan
Jan on 6 Mar 2017
It should work. Please try it again:
axes('nextplot, 'add'); % Like "hold on"
disk1 = patch('xdata', xcirc1(:,1), 'ydata', ycirc1(:,1), 'zdata', zcirc1(:,1));
disk2 = patch('xdata', xcirc2(:,1), 'ydata', ycirc2(:,1), 'zdata', zcirc2(:,1));
for ii = 1:length(y)
set(disk1, 'xdata', xcirc1(:,ii), 'ydata', ycirc1(:,ii), 'zdata', zcirc1(:,ii));
set(disk2, 'xdata', xcirc2(:,ii), 'ydata', ycirc2(:,ii), 'zdata', zcirc2(:,ii));
drawnow
pause(0.01)
end
If the coordinates are not Inf or NaN and are within the axes limits and the view direction is not parallel to the planes of the circles, the patches must be visible.
  1 Comment
aleksander maz
aleksander maz on 6 Mar 2017
Many thanks Jan, in your footnote you mentioned many vital aspects. for me I forgot to check my axes limits.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!