Why do plot related commands by default overwrite existing axes properties in MATLAB?

1 view (last 30 days)
I have three figure windows and execute HOLD ON without specifying to which axes I want to apply HOLD ON. The axes I am interested in is not currently in focus, thus the subsequent plot destroys the properties and callbacks of the axes in question. If the PLOT command did not destroy axes properties by default, none of this would not have happened. I want to know why the decision was made that plot-related commands by default destroy the axes properties as opposed to retain those in subsequent plotting commands.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 7 Jul 2011
MATLAB used to work on old consoles that had no windowing system. If you called PLOT, then it would switch to graphics mode and draw the plot. You then had to hit ESC or something to get the command line back. If you called plot again, it would start over. There was no handle graphics at the time. Translating this to a window system, it now looks like the following:
% >> do some hard math stuff
plot(mydata)
% >> think then do more math stuff.
plot(mydata)
In this case, the second plot replaces the first, instead of adding to it. If you want two lines in the figure that is where HOLD ON comes in. That is why the axes properties are replaced by default. The question to ask is if the axes had been configured because someone wrote a script that adds titles for instance, should those features stay on the axes when the data is replaced? The answer is no, this is a new fresh plot unless the user specified that it should not be.

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products


Release

R2009a

Community Treasure Hunt

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

Start Hunting!