Setup Default Property at startup

10 次查看(过去 30 天)
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

采纳的回答

Cindy Solomon
Cindy Solomon 2015-6-5
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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by