Plot disappears after axes command

56 views (last 30 days)
I have a GUI where i plot two curves in the same figure. later in the program i want to plot a third curve in the same figure. To do so i first choose that figure to plot in with the axes command. When i do so one of the previous curves disappears and i can't understand why. Someone who knows?
Stephen on 27 Jul 2016
Actually the axes documentation does describe one syntax which lets you provide an axes handle and it will make those axes the current axes: " axes(h) makes existing axes h the current axes and brings the figure containing it into focus"
However I would advise against using this in serious code, and instead always explicitly specify the axes in every plot function:
Almost all plot functions support this, and it is ultimately much simpler and much more robust. It prevents users' clicking from changing the behavior of your code!

Sign in to comment.

Accepted Answer

Joakim Magnusson
Joakim Magnusson on 27 Jul 2016
The command:
set(gcf, 'currentaxes', handles.viewCAM_handles.axes_posVelMA)
did the trick. Now I have trouble with wrong y-axis values but that's another problem.
Joakim Magnusson
Joakim Magnusson on 27 Jul 2016
Nice! I didn't know that, thanks!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by