Thread Subject: Default properties for figures and axes

Subject: Default properties for figures and axes

From: Petr Krysl

Date: 9 Jan, 2008 19:41:02

Message: 1 of 3

I've always used programmatic means of setting the
properties of figures to match my preferences. However, I
was not happy: I would have liked to change the defaults
that Matlab used for figures and axes. In other words, set
the defaults once, and when you say “figure” you will get
the correct colors, fonts (name, slant, size), tick
directions, marker size, in other words all the settings
will be to your satisfaction.

Here is what I found out would work. It uses undocumented
properties of the root. I put this into a script that I run
when I start Matlab working on a project where I need the
figures to look a certain way:

set(0, ‘DefaultFigureColor’, ‘White’, …
‘DefaultFigurePaperType’, ‘a4letter’, …
‘DefaultAxesColor’, ‘white’, …
‘DefaultAxesDrawmode’, ‘fast’, …
‘DefaultAxesFontUnits’, ‘points’, …
‘DefaultAxesFontSize’, 14, …
‘DefaultAxesFontAngle’, ‘Italic’, …
‘DefaultAxesFontName’, ‘Times’, …
‘DefaultAxesGridLineStyle’, ‘:’, …
‘DefaultAxesInterruptible’, ‘on’, …
‘DefaultAxesLayer’, ‘Bottom’, …
‘DefaultAxesNextPlot’, ‘replace’, …
‘DefaultAxesUnits’, ‘normalized’, …
‘DefaultAxesXcolor’, [0, 0, 0], …
‘DefaultAxesYcolor’, [0, 0, 0], …
‘DefaultAxesZcolor’, [0, 0, 0], …
‘DefaultAxesVisible’, ‘on’, …
‘DefaultLineColor’, ‘Red’, …
‘DefaultLineLineStyle’, ‘-’, …
‘DefaultLineLineWidth’, 2, …
‘DefaultLineMarker’, ‘none’, …
‘DefaultLineMarkerSize’, 8, …
‘DefaultTextColor’, [0, 0, 0], …
‘DefaultTextFontUnits’, ‘Points’, …
‘DefaultTextFontSize’, 14, …
‘DefaultTextFontName’, ‘Times’, …
‘DefaultTextVerticalAlignment’, ‘middle’, …
‘DefaultTextHorizontalAlignment’, ‘left’);

What I would like to check is whether it is a bad idea to
use these undocumented properties, and if so if there is a
better approach out there. Suggestions or comments, anyone?

Regards,

Petr

Subject: Default properties for figures and axes

From: Yair Altman

Date: 9 Jan, 2008 20:46:01

Message: 2 of 3

"Petr Krysl" <pkryslNOSP@Mucsd.edu> wrote in message
<fm380e$obl$1@fred.mathworks.com>...
> I've always used programmatic means of setting the
> properties of figures to match my preferences. However, I
> was not happy: I would have liked to change the defaults
> that Matlab used for figures and axes. In other words, set
> the defaults once, and when you say “figure” you will get
> the correct colors, fonts (name, slant, size), tick
> directions, marker size, in other words all the settings
> will be to your satisfaction.
>
> Here is what I found out would work. It uses undocumented
> properties of the root. I put this into a script that I run
> when I start Matlab working on a project where I need the
> figures to look a certain way:
>
> set(0, ‘DefaultFigureColor’, ‘White’, …
<snip>
> What I would like to check is whether it is a bad idea to
> use these undocumented properties, and if so if there is a
> better approach out there. Suggestions or comments, anyone?
>
> Regards,
>
> Petr


Actually, this is entirely documented and not at all a bad
idea:
http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f7-21465.html

You can set default property values at the axes, figure and
root levels - all these are documented and fully supported.

p.s. - You can also set the default value at the base class
(schema.prop) level, but this is indeed undocumented.

Yair Altman
http://ymasoftware.com

Subject: Default properties for figures and axes

From: Petr Krysl

Date: 10 Jan, 2008 01:24:02

Message: 3 of 3

Yair,

Thank you so much for this link.

> Actually, this is entirely documented and not at all a bad
> idea:
>
http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f7-21465.html
>

Inspired by your find I continued my digging in the
documentation, and found at least one other place where the
defaults are discussed:

You can set default axes properties on the figure and root
levels:set(0,'DefaultAxesPropertyName',PropertyValue,...)
set(gcf,'DefaultAxesPropertyName',PropertyValue,...)where
PropertyName is the name of the axes
property and PropertyValue is the value you are specifying.
Use set and get to
access axes properties.

So the documentation is there, it's just not terribly easy
to find. And, importantly, setting up the default values
this way is safe.

Thanks again,

Petr


Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
documented Steven Lord 5 Feb, 2008 18:59:26
undocumented Yair Altman 9 Jan, 2008 15:50:08
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com