fontsize

Sets the font size of the text in a figure or graphics object.

Category: Graphics > Formatting and Annotation

Syntax

fontsize(size, units)

Sets the font size for the text in the current figure, with units such as 'points'.

fontsize(obj, size, units)

Sets the size for the container obj and the text inside it.

fontsize('increase')

Makes the font about 10 percent larger. 'decrease' makes it smaller and 'default' restores the default.

Description

fontsize changes the size of all the text in the target at once: tick labels, axis labels, titles and legends. It is quicker than setting FontSize on each object.

With the keywords 'increase' and 'decrease' the size changes by a fixed factor from its current value, which is convenient to try a more readable figure without picking a number.

Input arguments

size
Positive number, the new font size, or one of the keywords 'increase', 'decrease', 'default'.
units
Unit of size, normally 'points'.
obj
Handle to a figure, axes or other graphics object.

Example

Larger text on a plot

plot(1:4)
xlabel('index')
fontsize(14, 'points')
ax = gca;
ax.FontSize
Output
ans = 14

Notes

In MatLivre the size is applied to the axes of the figure, and the units argument is accepted but not used to convert the value.

See also

fontname title xlabel text gca