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

2 次查看(过去 30 天)
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.

采纳的回答

MathWorks Support Team
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

产品


版本

R2009a

Community Treasure Hunt

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

Start Hunting!

Translated by