rticklabels - Set or query r-axis tick labels - MATLAB (original) (raw)
Set or query _r_-axis tick labels
Syntax
Description
rticklabels([labels](#bvayrux-1-labels))
sets the_r_-axis tick labels for the current axes. Specifylabels
as a string array or a cell array of character vectors; for example, {'January','February','March'}
. If you specify the labels, then the _r_-axis tick values and tick labels no longer update automatically based on changes to the axes.
[rl](#bvayrux-1-rl) = rticklabels
returns the _r_-axis tick labels for the current axes.
rticklabels('auto')
sets an automatic mode, enabling the axes to determine the _r_-axis tick labels. Use this option if you set the labels and then want to set them back to the default values.
rticklabels('manual')
sets a manual mode, freezing the _r_-axis tick labels at the current values.
[m](#bvayrux-1-m) = rticklabels('mode')
returns the current value of the _r_-axis tick labels mode, which is either 'auto'
or 'manual'
. By default, the mode is automatic unless you specify the tick labels or set the mode to manual.
___ = rticklabels([pax](#bvayrux-1-pax),___)
uses the axes specified by pax
instead of the current axes. Specify ax
as the first input argument for any of the previous syntaxes.
Examples
Create a polar plot. Display tick marks and grid lines along the _r_-axis at the values 0.1, 0.3, and 0.5. Then, specify a label for each tick mark.
theta = linspace(0,2*pi); rho = theta/10; polarplot(theta,rho) rticks([0.1 0.25 0.5]) rticklabels({'r = .1','r = .3','r = .5'})
Create a polar plot and assign the polar axes object to the variable pax
. Ensure that rticks
and rticklabels
affect the polar axes you just created by specifying pax
as the first input argument to the functions.
theta = 0:0.01:2pi; rho = 50sin(2*theta); polarplot(theta,rho) pax = gca;
rticks(pax,[10 25 50]) rticklabels(pax,{'r = 10','r = 25','r = 50'})
Create a polar plot and specify the _r_-axis tick values and corresponding labels. Then, set the _r_-axis tick values and labels back to the default values.
theta = linspace(0,2*pi); rho = theta/10; polarplot(theta,rho) rticks([0.1 0.25 0.5]) rticklabels({'r = .1','r = .3','r = .5'})
rticks('auto') rticklabels('auto')
Remove the tick labels along the _r_-axis by specifying the tick labels as an empty array.
theta = 0:0.01:2pi; rho = 50sin(2*theta); polarplot(theta,rho) rticklabels({})
Input Arguments
Tick labels, specified as a cell array of character vectors, string array, or categorical array. If you do not want tick labels to show, then specify an empty cell array {}
. Tick labels support TeX and LaTeX markup. See the TickLabelInterpreter property of the axes object for more information.
Example: rticklabels({'0','\pi','2\pi'})
Example: rticklabels({'January','Febrary','March'})
Example: rticklabels({})
Note
- To specify the tick values, use the rticks function.
- If you do not specify enough labels for all the ticks values, MATLAB® uses the labels followed by empty character vectors for the remaining ticks.
- If you specify the tick labels as a categorical array, MATLAB uses the values in the array, not the categories.
Polar axes, or an array of polar axes. If you do not specify this argument, then rticklabels
modifies the current axes (provided that the current axes is a polar axes object).
Output Arguments
Current tick labels, returned as a cell array of character vectors or a character array.
Current tick labels mode, returned as one of these values:
'auto'
— Axes automatically determines the _r_-axis tick labels.'manual'
— Axes uses manually specified _r_-axis tick labels.
More About
The tick labels are the labels that you see next to each tick mark. The tick values are the locations along the _r_-axis where the tick marks appear. Set the tick values using the rticks function. Set the corresponding tick labels using the rticklabels
function.
Algorithms
The rticklabels
function sets and queries several polar axes properties related to the _r_-axis tick labels.
- RTickLabel — Property that stores the text for the _r_-axis tick labels.
- RTickLabelMode — Property that stores the _r_-axis tick label mode. When you set the _r_-axis tick labels using
rticklabels
, this property changes to'manual'
. - RTickMode — Property that stores the _r_-axis tick value mode. When you set the _r_-axis tick labels using
rticklabels
, this property changes to'manual'
.
Version History
Introduced in R2016b