College of Natural Sciences
 
FAQs
This is for IE7 to hold div open

2.2.1. Fonts

How do I change the font of labels?

When you change the default font name and font size, the factory settings will still be used when drawing the title and lables on the screen. Following is a modified xlabel , ylabel , zlabel , and title to recognize changes to the default FontName and FontSize ; however, it would be just as easy to have it recognize changes to all the default text font properties. Below are the revised programs:

<------- XLABEL.M ------->

function xlabel(string)

% XLABEL X-axis labels for 2-D and 3-D plots.

% XLABEL('text') adds text below the X-axis on the current % axis.

%

% See also YLABEL, ZLABEL, TITLE, TEXT.

% Copyright (c) 1984-92 by The MathWorks, Inc.

h = get(gca,'xlabel');

ht = get(text,'fontname');

hs = get(text,'fontsize');

if isempty(h)

h = text('HorizontalAlignment','center');

set(gca,'xlabel',h);

end

set(h,'string',string,'fontname',ht,'fontsize',hs);

<------- YLABEL.M ------->

function ylabel(string)

% YLABEL Y-axis labels for 2-D and 3-D plots.

% YLABEL('text') adds text beside the Y-axis on the current % axis.

%

% See also XLABEL, ZLABEL, TITLE, TEXT.

% Copyright (c) 1984-92 by The MathWorks, Inc.

h = get(gca,'ylabel');

ht = get(text,'fontname');

hs = get(text,'fontsize');

if isempty(h)

h = text;

set(gca,'ylabel',h);

end

set(h,'string',string,'fontname',ht,'fontsize',hs);

<------- ZLABEL.M ------->

function zlabel(string)

% ZLABEL Z-axis labels for 3-D plots.

% ZLABEL('text') adds text above the Z-axis on the current % axis.

%

% See also XLABEL, YLABEL, TITLE, TEXT.

% Copyright (c) 1984-92 by The MathWorks, Inc.

h = get(gca,'zlabel');

ht = get(text,'fontname');

hs = get(text,'fontsize');

if isempty(h)

h = text;

set(gca,'zlabel',h);

end

set(h,'string',string,'fontname',ht,'fontsize',hs);

<------- TITLE.M ------->

function title(string)

% TITLE Titles for 2-D and 3-D plots.

% TITLE('text') adds text at the top of the current axis.

%

% See also XLABEL, YLABEL, ZLABEL, TEXT.

% Copyright (c) 1984-92 by The MathWorks, Inc.

h = get(gca,'title');

ht = get(text,'fontname');

hs = get(text,'fontsize');

if isempty(h)

h = text('horiz','center');

set(gca,'title',h);

end

set(h,'string',string,'fontname',ht,'fontsize',hs);

For more information, see the MATLAB technical note written on this topic. It is located on the ftp site in pub/tech-support/tech-notes/gr2.txt.