Main Content

rticklabels

Set or query r-axis tick labels

Description

rticklabels(labels) sets the r-axis tick labels for the current axes. Specify labels 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.

example

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.

example

rticklabels('manual') sets a manual mode, freezing the r-axis tick labels at the current values.

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,___) uses the axes specified by pax instead of the current axes. Specify ax as the first input argument for any of the previous syntaxes.

example

Examples

collapse all

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'})

Figure contains an axes object with type polaraxes. The polaraxes object contains an object of type line.

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:2*pi;
rho = 50*sin(2*theta);
polarplot(theta,rho)
pax = gca;

rticks(pax,[10 25 50])
rticklabels(pax,{'r = 10','r = 25','r = 50'})

Figure contains an axes object with type polaraxes. The polaraxes object contains an object of type line.

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'})

Figure contains an axes object with type polaraxes. The polaraxes object contains an object of type line.

rticks('auto')
rticklabels('auto')

Figure contains an axes object with type polaraxes. The polaraxes object contains an object of type line.

Remove the tick labels along the r-axis by specifying the tick labels as an empty array.

theta = 0:0.01:2*pi;
rho = 50*sin(2*theta);
polarplot(theta,rho)
rticklabels({})

Figure contains an axes object with type polaraxes. The polaraxes object contains an object of type line.

Input Arguments

collapse all

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

collapse all

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

collapse all

Tick Labels

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.

Tick marks appear as circular lines along the r-axis. Tick labels for tick values appear as text directly on each tick mark line.

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