ytickformat
Gets or sets the number format of the y-axis tick labels.
Category: Graphics > Formatting and Annotation
Syntax
ytickformat(fmt)
Formats the tick labels with fmt, a sprintf-style specification such as '%.1f', or a name like 'usd'.
f = ytickformat
Returns the current format.
ytickformat(ax, ___)
Acts on the axes ax.
Description
The format controls how the numbers at the ticks are written, without changing where the ticks are. Adding a unit ('%d%%') or fixing the number of decimals avoids labels such as 0.30000000004.
If the labels were set by hand with yticklabels, the format has no visible effect until yticklabels('auto') is called.
Input arguments
fmt- Text such as
'%d%%'or'%.2f', or'usd','eur'for currency. For datetime axes it is a datetime format such as'MMM dd'.
Output arguments
f- Current format as text.
Example
Currency labels
plot(1:4, [10 25 40 55])
yticks([10 25 40 55])
ytickformat('usd')
f = ytickformat
yticklabels
Output
f = 'usd'
ans = 4×1 cell
{'$10.00'}
{'$25.00'}
{'$40.00'}
{'$55.00'}