Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

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.

Contact us