reset plot layout settings

14 views (last 30 days)
HUANG WENXUAN
HUANG WENXUAN on 24 Sep 2015
Answered: Walter Roberson on 24 Sep 2015
Usually, I have multiple scripts and each scripts has:
clc
clear all
close all
at the top. However, sometimes after I run sciprt1.m, it sets some kind of subplot layout. Then when I use script2.m, I actually want to simply use 1 plot only on 1 figure... But somehow it still uses the subplot setting of script1.m (meaning 1 plot only occupies 1/4 of the whole figure) ....
I need to close matlab and reopen it to successfully make 1 plot only in 1 figure. How could I reset the plot setting so that there is no need to close and reopen matlab? Thank you

Answers (1)

Walter Roberson
Walter Roberson on 24 Sep 2015
If you really do have "clear all" and "close all" at the beginning of every script, then the only way that there could be any information left over about the plot layout is if your script had modified the DefaultAxesPosition property of the root graphics object.
"clear all" means to get rid of all graphics and all variables, but the Default* settings of the root object are not restored.
Your situation sounds much closer to the possibility that you still have an existing figure and an existing current axes that was created with subplot() and your plots are being done to the default current axes. Those conditions would disappear if you did a "clear all", so it does not sound like you have done that.
In my opinion, "clear all" should never be done from a script or a function, only from the command line, and only if your intention is to reset your MATLAB session. It should not be used casually. "close all" is not as bad, but it does presume that the script knows better than you do about whether you might still have wanted a figure displayed for comparison purposes; in my experience that is an arrogance that is not often justified.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!