Borrar filtros
Borrar filtros

How to stop seperate axes plotting over the top of one anotner?

1 visualización (últimos 30 días)
HC98
HC98 el 12 de Mayo de 2022
Respondida: Voss el 13 de Mayo de 2022
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?

Respuesta aceptada

Voss
Voss el 13 de Mayo de 2022
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

Más respuestas (0)

Categorías

Más información sobre Visual Exploration en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by