Change default figure properties?
Ältere Kommentare anzeigen
Is there any way to change the default figure properties in MATLAB?
For example, I want all my figures to have a certain axis font size, background color, xlabel/ylabel font size, and line width. Nothing fancy, just want to change some basic default settings.
I know how to do this for each individual plot in my scripts. However, I am generating several different types of plots (plot, hist, surf, etc) and a lot of them from several different scripts.
Thanks for any help with this.
2 Kommentare
Richa Singh
am 23 Jan. 2021
Yes, there is.. I am using it for all my matlab figures.
set(groot,'defaultLineLineWidth',2.5)
set(0,'DefaultaxesLineWidth', 1.5)
set(0,'DefaultaxesFontSize', 14)
set(0,'DefaultaxesFontWeight', 'bold')
set(0,'DefaultTextFontSize', 14)
set(0,'DefaultaxesFontName', 'Times new Roman')
set(0,'DefaultlegendFontName', 'Times new Roman')
set(0,'defaultAxesXGrid','on')
set(0,'defaultAxesYGrid','on')
Ask Finderup
am 17 Jan. 2022
Do you know how to the reset those properties?
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 4 Mai 2012
Bearbeitet: Wendy Fullam
am 4 Feb. 2013
2 Stimmen
5 Kommentare
Robert Ralich
am 4 Mai 2012
Walter Roberson
am 4 Mai 2012
That link shows you how to set figure defaults. For example,
set(0, 'DefaultFigureBackground', [0.2 0.7 0.5]);
Daniel Shub
am 4 Mai 2012
A link to the relevant section of the page provided by Walter: http://www.mathworks.com/help/techdoc/creating_plots/f7-21465.html#f7-18841
David Christhilf
am 29 Aug. 2017
That seems to no longer work in R2017a.
I would very much like to kill the 'autoupdate' feature of 'legend' in one single global action. It seems there should be some way to set the default for the 'legend' aspect of 'plot'.
Steven Lord
am 29 Aug. 2017
David, you asked this as a separate question and the comment you left indicates you found a solution.
Ah, I see why you said this no longer works. The URL changed for the page to which Walter link; the updated address is:
https://www.mathworks.com/help/matlab/creating_plots/default-property-values.html
Or you can search for the phrase "default property values" and that should work regardless of which release you're using. The version of that page appropriate for the release you're using should be among the first page of hits, if not the first hit.
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!