How to restrict a background from changing?

1 vue (au cours des 30 derniers jours)
Brennan Schilling
Brennan Schilling le 23 Août 2017
Réponse apportée : Adam le 23 Août 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

Réponses (1)

Adam
Adam le 23 Août 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.

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by