Borrar filtros
Borrar filtros

Only plotting on the last of three axes?

1 visualización (últimos 30 días)
Harry Smith
Harry Smith el 16 de Nov. de 2017
Comentada: Harry Smith el 16 de Nov. de 2017
I have three axes on the same figure. Each axes has its own plot function. The first time the code runs it prints on the correct axes. On the second time the functions are called, all three plots are shown in the last axes in sequence Tried cla, cla reset, and many others Does this have an obvious solution which I am missing?

Respuesta aceptada

Guillaume
Guillaume el 16 de Nov. de 2017
Each axes has its own plot function. What does that mean?
If a figure has several axes, that means you used subplot to create the axis. You need to save the handle of these axis in order to replot in them:
figure;
hax(1) = subplot(1, 3, 1); %save handle of 1st axis
plot(sin(linspace(0, 2*pi, 200)));
hax(2) = subplot(1, 3, 2); %save handle of 2nd axis
plot(sqrt(linspace(0, 5, 200)));
hax(3) = subplot(1, 3, 3); %save handle of 3rd axis
plot(log(linspace(0, 5 , 200)));
To replot in all axis
plot(hax(1), tan(linspace(0, 2*pi, 200))); %plot in first axis
plot(hax(2), linspace(0, 5, 200).^2); %plot in second axis
plot(hax(3), exp(linspace(0, 5, 200))); %plot in 3rd axis
Alternatively, if you don't want to store the axis, you can reissue the subplot command:
subplot(1, 1, 1); %replot in first axis
plot(cos(linspace(0, 2*pi, 200)));
subplot(1, 1, 2); %replot in second axis
plot(linspace(0, 5, 200));
subplot(1, 1, 2); %replot in 3rd axis
  1 comentario
Harry Smith
Harry Smith el 16 de Nov. de 2017
Thanks Not use subplot, only plot
I will read and learn, many thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by