Setup Default Property at startup

11 views (last 30 days)
Dear all,
I regularly change the default values for graphical properties in my startup.m file like
set(0,'DefaultAxesFontName','times');
to set all axes fonts to times.
Recently after updating to R2015a I have an issue when creating pdf/ps file of my figures where the grid lines are hardly visible. I figured out a trick to see them is to set GridAlpha to 1 and GridColor to [0.1 0.1 0.1] as set(gca,'GridLineStyle',':','GridAlpha',1,'GridColor',[0.1 0.1 0.1])
Now I tried to put the following statements in my startup.m file
set(0,'DefaultGridAlpha',1); set(0,'DefaultGridColor',[0.1 0.1 0.1]);
but I get the following error message
Warning: Executing startup failed in matlabrc. This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was: MATLAB:hgutils:InvalidClassName gridalpha is an invalid class name
My question is how to change the default value of these properties?
Thank you for your help

Accepted Answer

Cindy Solomon
Cindy Solomon on 5 Jun 2015
Hi Patrick,
To define a default property value, you need to specify a string with the word 'default', the object type (ex: Axes), and the property name (ex: Grid Alpha). For example, in order to set the properties you mentioned, you would do:
set(groot,'DefaultAxesGridAlpha',1);
set(groot,'DefaultAxesGridColor',[0.1 0.1 0.1]);
As of R2014b, MathWorks released a new graphics system wherein graphics handles are now objects instead of doubles. In doing so, you can more easily define properties of a particular level. In addition, the "root object" is now called "groot" (graphics root), although you should still be able to use 0 to set default values. For more information on setting default values, I recommend looking at this page.
Hope this helps!

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!