Setup Default Property at startup

조회 수: 10 (최근 30일)
Patrick
Patrick 2015년 6월 4일
답변: Cindy Solomon 2015년 6월 5일
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