turn off yyaxis mode

86 visualizaciones (últimos 30 días)
Jakob Seifert
Jakob Seifert el 19 de Mzo. de 2021
Comentada: alejandro paradiso el 24 de Mayo de 2023
Hi,
i tried to solve my problem but could not find any solutions.
The problem: If i plot two data sets with two different y axes, the subsequent plots also have two y axes. Example:
x = 1:10;
y1 = x.^2;
y2 = x;
hold on
yyaxis left
plot(x,y1)
yyaxis right
plot(x,y2)
hold off
plot(x,y1)
I tried to insert the hold command on different positions but everytime the next plot isn't working as i want it to:
So my question is, how do i get a "normal" plot after yyaxis was used.
The answer is probably very easy, but I'm not very into MatLab yet, so sorry in advance for this question ._.
If the question was already asked and answered a link to that discussion would be helpful as well :)
~Jakob

Respuesta aceptada

Walter Roberson
Walter Roberson el 19 de Mzo. de 2021
You are using LiveScript, which has its own rules for deciding when to plot things or not.
Experiment with using
clf
at the point that you want to switch back to single axes.
  2 comentarios
Jakob Seifert
Jakob Seifert el 19 de Mzo. de 2021
yes it did work, thank you :)
alejandro paradiso
alejandro paradiso el 24 de Mayo de 2023
this tip should be mentioned in the yyaxis function description, because after using it, the graph is repeated randomly in a sort of glitch

Iniciar sesión para comentar.

Más respuestas (1)

Achilleas Vortselas
Achilleas Vortselas el 19 de Mzo. de 2021
Instead of clf, you can also use:
cla(gca,'reset')
The benefit of that is if the axis is inside a GUI and not a Matlab figure, or if the figure has additional children aside from the axis.
  2 comentarios
Walter Roberson
Walter Roberson el 19 de Mzo. de 2021
No, in this case it is not enough to cla. When you use plotyy(), two axes are created, and cla() will not get rid of the other one.
Achilleas Vortselas
Achilleas Vortselas el 20 de Mzo. de 2021
That's why reset is there. The documentation says so (at the very bottom of the page).
Also, I have been using it and it works.

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by