How to stop seperate axes plotting over the top of one anotner?
2 次查看(过去 30 天)
显示 更早的评论
I have some code which plots on the same figure a smaller set of axes to zoom in on a specific area of the plot. This works great:
x = [-10:1E-3:10];
y = sin(x);
figure(1)
plot(x, y)
grid on
box on
axes('Position',[.40 .33 .45 .24])
plot(x,y)
ylim([0, 1])
title('Closer look')
grid on
box off
But the problem is, when I run the script again, it plots over the top of the previous set of iset axes and creates a mess. Any way to fix this?
0 个评论
采纳的回答
Voss
2022-5-13
One way would be to plot into a new figure each time, instead of specifying to plot into figure 1 each time:
x = [-10:1E-3:10];
y = sin(x);
% figure(1)
figure() % create a new figure
plot(x, y)
grid on
box on
axes('Position',[.40 .33 .45 .24])
plot(x,y)
ylim([0, 1])
title('Closer look')
grid on
box off
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!