From: Andrew Stevens on
Hi,

I am trying to change the default font for figures and can't find the command. I tried:

get(0,'default')

but there does not seem to be a 'defaultfontname'. I also tried creating the figure and using:

h=findobj(gca,'type','text');
set(h,'fontname','arial')

In that case, the x- and y- labels were not changed. There has to be a way to change the default font so I don't have to type it out for every object in the fig.

Andrew
From: Andrew Stevens on
"Andrew Stevens" <astevens(a)JUNKusgs.gov> wrote in message <hv5op9$cq2$1(a)fred.mathworks.com>...
> Hi,
>
> I am trying to change the default font for figures and can't find the command. I tried:
>
> get(0,'default')
>
> but there does not seem to be a 'defaultfontname'. I also tried creating the figure and using:
>
> h=findobj(gca,'type','text');
> set(h,'fontname','arial')
>
> In that case, the x- and y- labels were not changed. There has to be a way to change the default font so I don't have to type it out for every object in the fig.
>
> Andrew

This is a bit interesting (maybe?)...As a hack (while I was waiting to hear from you all), I tried this to change the font of all objects in a figure:

%first created a figure and added labels, text anotations, etc
h=findobj(gcf);
ind2=cellfun(@(x)(any(strmatch('FontName',....
fieldnames(get(x))))),num2cell(h));
set(h(ind2),'fontname','arial')

The call to findobj does not seem to find the x- and y- labels. Maybe this is an intended behavior, but seems like a bug to me.

Andrew
From: Matt Fig on
There is no 'fontname' property for figures. I think you are looking for the axes properties. For example:

set(0,'defaultaxesfontname','Times New Roman')
From: us on
"Andrew Stevens" <astevens(a)JUNKusgs.gov> wrote in message <hv5op9$cq2$1(a)fred.mathworks.com>...
> Hi,
>
> I am trying to change the default font for figures and can't find the command. I tried:
>
> get(0,'default')
>
> but there does not seem to be a 'defaultfontname'. I also tried creating the figure and using:
>
> h=findobj(gca,'type','text');
> set(h,'fontname','arial')
>
> In that case, the x- and y- labels were not changed. There has to be a way to change the default font so I don't have to type it out for every object in the fig.
>
> Andrew

a hint:
- on how to change def graphics handle props...

http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f7-21465.html

us
From: Steven Lord on

"Andrew Stevens" <astevens(a)JUNKusgs.gov> wrote in message
news:hv5pi6$44m$1(a)fred.mathworks.com...
> "Andrew Stevens" <astevens(a)JUNKusgs.gov> wrote in message
> <hv5op9$cq2$1(a)fred.mathworks.com>...
>> Hi,
>>
>> I am trying to change the default font for figures and can't find the
>> command. I tried:
>>
>> get(0,'default') but there does not seem to be a 'defaultfontname'. I
>> also tried creating the figure and using:
>>
>> h=findobj(gca,'type','text');
>> set(h,'fontname','arial')
>>
>> In that case, the x- and y- labels were not changed. There has to be a
>> way to change the default font so I don't have to type it out for every
>> object in the fig.

us pointed you to the documentation on how to change the default property
value -- the general formula is:

set(<handle to some object>, 'Default<name of the object><property name>',
<new default value>)

This will make the default value for the property <property name> of all
<name of the object> objects that have <handle to some object> as an
ancestor be <new default value>. For example:

set(gcf, 'DefaultAxesColor', [1 0 0])

will make all Axes objects that have the current "current figure" as their
ancestor use [1 0 0] as the default value for their Color property. Note
that this will NOT change the _current_ value of the Color property of any
axes that _already exist_ in the figure; but if you were to take such an
existing axes and SET its Color property to 'default', it would use the new
default value of [1 0 0].

>> Andrew
>
> This is a bit interesting (maybe?)...As a hack (while I was waiting to
> hear from you all), I tried this to change the font of all objects in a
> figure:
>
> %first created a figure and added labels, text anotations, etc
> h=findobj(gcf);
> ind2=cellfun(@(x)(any(strmatch('FontName',....
> fieldnames(get(x))))),num2cell(h));
> set(h(ind2),'fontname','arial')
>
> The call to findobj does not seem to find the x- and y- labels. Maybe
> this is an intended behavior, but seems like a bug to me.

Not A Bug.

h = xlabel('hi');
get(h, 'HandleVisibility')

FINDOBJ does not find objects whose HandleVisibility property is set to
'off'. For that, you want FINDALL.

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/findall.html

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/text_props.html#HandleVisibility

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com