How to restrict a background from changing?

2 Ansichten (letzte 30 Tage)
Brennan Schilling
Brennan Schilling am 23 Aug. 2017
Beantwortet: Adam am 23 Aug. 2017
I have two guis, one with buttons and one with a plot. When the plot appears the gui with the buttons' background becomes an empty plot. How do I make sure this doesn't happen?
NOTE: I do not like this answer, I want something simpler and easier to understand: https://www.mathworks.com/matlabcentral/answers/262776-matlab-gui-showing-axis-at-the-background

Antworten (1)

Adam
Adam am 23 Aug. 2017
Plot functions and hold and all other similar functions take an axes handle as their first argument. Use it! So many people seem to just call plot or hold and hope for the best as to where it will actually get applied to. If you keep hold of your axes handle and just pass it to the hold instruction or whatever else you are calling (you haven't shown any code so I'm just guessing) then this won't happen.
If you call a function that expects to work on an axes and the current figure has no axes it will simply create one, however inappropriate this may seem to you, even if it is just doing so in order to set the 'hold' status to on.
All this can be avoided by common sense programming of explicitly telling your code which axes to act upon.

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by