rtickformat
Specify r-axis tick label format
Description
rtickformat(
sets
the format for the r-axis tick labels. For example,
specify fmt
)fmt
as 'usd'
to display
the labels in U.S. dollars.
returns the format style used for
r-axis tick labels of the current axes. Depending on
the type of labels along the r-axis,
rfmt
= rtickformatrfmt
is a character vector or string containing a
numeric format.
returns
the format style used for the axes specified by rfmt
= rtickformat(pax
)pax
instead
of the current axes.
Examples
Display r-Axis Tick Labels as Percentages
Create a polar plot. Display the tick labels along the r-axis as percentages.
th = linspace(0,2*pi,10); r = [11 49 95 68 74 75 88 76 65 67]; polarplot(th,r,'o') rtickformat('percentage')
Display Text After Each r-Axis Tick Label
Display the tick labels along the r-axis with the text "cm" after each value.
polarplot(1:10)
rtickformat('%g cm')
Control Number of Decimals for r-Axis Tick Labels
Display the r-axis tick labels with two decimal places. Control the decimal places by passing rtickformat
a character vector of a numeric format that uses fixed-point notation for the conversion character and a precision value of 2.
theta = 0:0.01:2*pi;
rho = 50*sin(2*theta);
polarplot(theta,rho)
rtickformat('%.2f')
Specify r-Axis Tick Label Format for Specific Polar Axes
Create a polar plot and assign the polar axes object to the variable pax
. Ensure that rtickformat
affects the polar axes you just created by passing pax
as the first input argument to the function.
polarplot(1:10)
pax = gca;
rtickformat(pax,'percentage')
Input Arguments
fmt
— Format for numeric tick labels
'%g'
(default) | character vector | string
Format for numeric tick labels, specified as a character vector or string. You can specify one of the formats listed in this table. Alternatively, you can specify a custom format.
Predefined Format | Description |
---|---|
'usd' |
U.S. dollars. This option is equivalent using
|
'eur' |
Euro. This option is equivalent to using
|
'gbp' |
British pound. This option is equivalent to using
|
'jpy' |
Japanese yen. This option is equivalent to using
|
'degrees' |
Display degree symbol after values. This option is
equivalent to using |
'percentage' |
Display percent sign after values. This option is
equivalent to using |
'auto' |
Default format of |
Example: rtickformat('usd')
Custom Numeric Format
You can specify a custom numeric format by creating a character vector or string containing identifiers.
Identifiers are optional, except the percent sign and conversion character. Construct the format in this order:
One or more flags — Options such as adding a plus sign before positive values. For a full list of options, see the table of Optional Flags.
Field width — Minimum number of characters to print in the tick label. Specify the field width as an integer value. If the number of significant digits in the tick value is smaller than the field width, then the label is padded with spaces.
Precision — Number of digits to the right of the decimal point or the number of significant digits, depending on the conversion character. Specify the precision as an integer value.
Conversion character — Value type. For a full list of options, see the table of Conversion Characters. If you specify a conversion that does not fit the data, then MATLAB® overrides the specified conversion, and uses
%e
.
Also, you can specify literal text at the beginning
or end of the format. To print a single quotation mark, use ''
.
To print a percent character, use %%
.
Example: rtickformat('%.2f')
displays
the values using fixed-point notation with two decimal places.
Example: rtickformat('$%.2f')
displays
a dollar sign before each value.
Example: rtickformat('%.2f
million')
displays million
after each
value.
Optional Flags
Identifier | Description | Example of Numeric Format |
---|---|---|
, | Display commas every three digits, such as '1,000' . | '%,4.4g' |
+ | Print the sign character (+) for positive values, such as '+100' . | '%+4.4g' |
0 | Pad the field width with leading zeros instead of spaces, such
as '0100' . | '%04.4g' |
– | Left-justify, which pads the end of the value with spaces instead
of the beginning. For example, if the field width is 4 ,
then this flag formats the label as '100 ' instead
of ' 100' . | '%-4.4g' |
# | For the | '%#4.4g' |
Conversion Characters
Identifier | Description | Example |
---|---|---|
d or i | Signed integer with base 10. The precision value indicates the number of significant digits. | '%.4d' displays π as 0003 . |
f | Fixed-point notation. The precision value indicates the number of decimal places. | '%.4f' displays π as 3.1416 . |
e | Exponential notation. The precision value indicates the number of decimal places. | '%.4e' displays π as 3.1416x100 . |
g | The more compact version of e or f ,
with no trailing zeros. The precision value indicates the maximum
number of decimal places. | '%.4g' displays π as 3.1416 . |
pax
— Polar axes
polar axes | array of polar axes
Polar axes, or an array of polar axes. If you do not specify this
argument, then rtickformat
modifies the current axes
(provided that the current axes is a polar axes object).
Algorithms
The rtickformat
function sets and queries
the TickLabelFormat
property of the ruler object
associated with the r-axis.
Version History
Introduced in R2016b
See Also
thetatickformat
| rticks
| rticklabels
| rtickangle
| rlim
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)