Below is a list of properties that both axes and text share:
Property Name Property Value FontAngle normal FontName Helvetica FontSize 12 FontWeight normalFontAngle refers to the angle of the font. By default, this is normal; however, the possible settings for this property are:
Settings Description normal Normal font italic Italic font oblique Oblique fontExample:
h = text(0.5,0.5, 'This is italics text'); set(h, 'FontAngle', 'italic') set(gca,'FontAngle','oblique')FontName refers to the name of the font. Currently, MATLAB supports the following eleven font families:
Avante Garde Palatino Bookman Symbol Courier Times Helvetica Zapf Chancery Helvetica Narrow Zapf Dingbats New Century SchoolbookThe default font is Helvetica.
Example:
h = text(0.5,0.5, 'This is Courier font text'); set(h, 'FontName', 'Courier') set(gca,'FontName','Bookman')FontSize is the point size of the font. By default, this is set to 12; however, you can set this to any font size, assuming your machine has the font installed. (Note: one point = 1/72 inch)
Example:
h = text(0.5,0.5, 'This is 16-point text'); set(h, 'FontSize', 16) set(gca,'FontSize',10)FontWeight refers to the weight of the font. By default, this is set to normal. The other possible settings are:
Weight Description bold Bold weight font demi Medium bold weight font light Fine weight font normal Normal weight fontExample:
h = text(0.5,0.5, 'This is bold text'); set(h, 'FontWeight', 'bold') set(gca,'FontWeight','light')These settings can be combined to create almost any combination that your machine supports. For example, to specify a 10-point Helvetica-Bold Oblique font, do one of the following:
h = text(X,Y,'Text String','FontName','Helvetica', ... 'FontSize',10,'FontWeight','bold','FontAngle', ... 'oblique'); h = text(X,Y,'Text String'); set(h,'FontName','Helvetica','FontSize',10, ... 'FontWeight','bold','FontAngle','oblique');where X and Y are the x and y coordinates.
If your machine does not support a particular font, then MATLAB uses the following rules for selecting the current font:
Example:
title('This is the title') h = get(gca, 'title'); set(h, 'FontName', 'Helvetica')Use the same procedure to set the FontName of labels (xlabels, ylabels, and zlabels).
Example:
xlabel('This is the label') h = get(gca, 'xlabel'); set(h, 'FontName', 'Times')
set(<ancestor>, 'Default<object type><property name>', ... <property value>)For example, the following sets the default FontName used by text to Symbol for the current axes only:
set(gca, 'DefaultTextFontName', 'symbol')To specify the default FontName for the current figure, use gcf as the handle. To specify the default for the entire session, use 0.
Setting the default FontName of text will affect all text objects. Setting the default FontName will set the font used for axis labels, titles, and tick mark labels.
(c) Copyright 1994 by The MathWorks, Inc.