polaraxes
Create polar axes
Description
polaraxes
creates the default polar axes in the current
figure.
polaraxes(
specifies
properties for the Name,Value
)PolarAxes
object using one
or more name-value pair arguments, for example,
'ThetaDir','clockwise'
. For a list of properties, see
PolarAxes Properties.
polaraxes(
creates the polar axes in the figure, panel, or tab specified by
parent
,___)parent
, instead of in the current figure. Use this option
alone or with name-value pair arguments.
returns
the pax
= polaraxes(___)PolarAxes
object created. Use
pax
to query and set properties of the PolarAxes
object after it is created. For a list
of properties, see PolarAxes Properties.
Examples
Modify Polar Axes Properties
Create a new figure with polar axes and assign the polar axes object to pax
. Add a plot to the axes. Then, use pax
to modify axes properties.
figure
pax = polaraxes;
theta = 0:0.01:2*pi;
rho = sin(2*theta).*cos(2*theta);
polarplot(theta,rho)
pax.ThetaDir = 'clockwise';
pax.FontSize = 12;
Before R2022a, polar axes do not include degree symbols by default. To add them, get the polar axes using pax = gca
. Then modify the tick labels using pax.ThetaTickLabel = string(pax.ThetaTickLabel) + char(176)
.
Make Polar Axes Current Axes
Create a figure with polar axes and assign the polar axes object to pax
. Then, ensure pax
is the current axes before calling the polarplot
function.
figure pax = polaraxes; polaraxes(pax) polarplot(1:10)
Input Arguments
parent
— Parent container
Figure
object | Panel
object | Tab
object | TiledChartLayout
object | GridLayout
object
Parent container, specified as a Figure
, Panel
,
Tab
, TiledChartLayout
, or GridLayout
object.
pax_in
— Polar axes to make current
PolarAxes
object
Polar axes to make current, specified as a PolarAxes
object.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: 'ThetaZeroLocation','top','ThetaDir','clockwise'
The properties listed here are only a subset. For a complete list, see PolarAxes Properties. Some graphics functions reset axes properties when plotting. To avoid graphics functions from overriding the property values, set axes properties after plotting.
ThetaAxisUnits
— Units for angle values
'degrees'
(default) | 'radians'
Units for angle values, specified as one of these values:
'degrees'
— Label the angles in degrees, and interpret theThetaLim
,ThetaTick
, andRAxisLocation
property values in degrees. When you switch the units from radians to degrees, MATLAB® converts the radian values in those three properties to the equivalent degree values.'radians'
— Label the angles in radians, and interpret theThetaLim
,ThetaTick
, andRAxisLocation
property values in radians. When you switch the units from degrees to radians, MATLAB converts the degree values in those three properties to the equivalent radian values.
Example: ax.ThetaAxisUnits = 'radians';
ThetaZeroLocation
— Location of the zero reference axis
'right'
(default) | 'top'
| 'left'
| 'bottom'
Location of the zero reference axis, specified as one of the values in this table.
Value | Result |
---|---|
'right' |
|
'top' |
|
'left' |
|
'bottom' |
|
Example: ax.ThetaZeroLocation = 'left';
ThetaDir
— Direction of increasing angles
'counterclockwise'
(default) | 'clockwise'
Direction of increasing angles, specified as one of the values in this table.
Value | Result |
---|---|
'counterclockwise' | Angles increase in a counterclockwise direction. |
'clockwise' | Angles increase in a clockwise direction. |
Example: ax.ThetaDir = 'clockwise';
ThetaLim
— Minimum and maximum angle values
[0 360]
(default) | two-element vector of the form [thmin thmax]
Minimum and maximum angle values, specified as a two-element
vector of the form [thmin thmax]
. If the difference
between the values is less than 360 degrees, then the theta-axis is
a partial circle.
MATLAB interprets the values in units determined by the ThetaAxisUnits
property.
Example: ax.ThetaLim = [0 180];
ThetaTick
— Angles at which to display lines
[0 30 60 ... 300 330 360]
(default) | vector of increasing values
Angles at which to display lines extending from the origin,
specified as a vector of increasing values. MATLAB labels the
lines with the appropriate angle values, unless you specify different
labels using the ThetaTickLabel
property.
MATLAB interprets the values in units determined by the ThetaAxisUnits
property.
Example: ax.ThetaTick = [0 90 180 270];
Alternatively, specify the values using the thetaticks
function.
ThetaColor
— Color of theta-axis
[0.15 0.15 0.15]
(default) | RGB triplet | hexadecimal color code | 'r'
| 'g'
| 'b'
| ...
Color of the theta-axis, including the theta-axis grid lines, tick marks, tick labels. Specify this value as an RGB triplet, a hexadecimal color code, a color name, or a short name.
Note
If you specify the GridColor
property, then the grid lines use
the color in the GridColor
property instead. See GridColorMode
for more
information.
For a custom color, specify an RGB triplet or a hexadecimal color code.
An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range
[0,1]
, for example,[0.4 0.6 0.7]
.A hexadecimal color code is a string scalar or character vector that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. The values are not case sensitive. Therefore, the color codes"#FF8800"
,"#ff8800"
,"#F80"
, and"#f80"
are equivalent.
Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"red" | "r" | [1 0 0] | "#FF0000" | |
"green" | "g" | [0 1 0] | "#00FF00" | |
"blue" | "b" | [0 0 1] | "#0000FF" | |
"cyan"
| "c" | [0 1 1] | "#00FFFF" | |
"magenta" | "m" | [1 0 1] | "#FF00FF" | |
"yellow" | "y" | [1 1 0] | "#FFFF00" | |
"black" | "k" | [0 0 0] | "#000000" | |
"white" | "w" | [1 1 1] | "#FFFFFF" | |
"none" | Not applicable | Not applicable | Not applicable | No color |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[0 0.4470 0.7410] | "#0072BD" | |
[0.8500 0.3250 0.0980] | "#D95319" | |
[0.9290 0.6940 0.1250] | "#EDB120" | |
[0.4940 0.1840 0.5560] | "#7E2F8E" | |
[0.4660 0.6740 0.1880] | "#77AC30" | |
[0.3010 0.7450 0.9330] | "#4DBEEE" | |
[0.6350 0.0780 0.1840] | "#A2142F" |
For example, ax.ThetaColor = 'r'
changes the color to red.
RAxisLocation
— Location of r-axis
80
(default) | scalar angle value
Location of the r-axis, specified a scalar angle value. MATLAB interprets
the values in units determined by the ThetaAxisUnits
property.
Example: ax.RAxisLocation = 90;
RDir
— Direction of increasing values along r-axis
'normal'
(default) | 'reverse'
Direction of increasing values along the r-axis, specified as one of these values:
'normal'
— Values increase outward from the center of the chart. The radius at the origin corresponds to the minimum value stored in theRLim
property (typically 0).'reverse'
— Values decrease outward from the center of the chart. The radius at the origin corresponds to the maximum value stored in theRLim
property.
Example: ax.RDir = 'reverse';
RLim
— Minimum and maximum radius limits
[0 1]
(default) | two-element vector of the form [rmin rmax]
Minimum and maximum radius limits, specified as a two-element
vector of the form [rmin rmax]
, where rmax
is
a numeric value greater than rmin
. You can specify
both limits, or specify one limit and let the axes automatically calculate
the other.
To automatically set the minimum limit to the minimum data value, specify the first element as
-inf
, for example,[-inf 0]
.To automatically set the maximum limit to the maximum data value, specify the second element as
inf
, for example,[0 inf]
.
Alternatively, use the rlim
function
to set the limits.
Example: ax.RLim = [0 6];
RTick
— Radius tick values
[0 0.2 0.4 0.6 0.8 1]
(default) | vector of increasing values
Radius tick values, specified as a vector of increasing values. The radius tick values
are the locations along the r-axis where the circular lines appear.
The radius tick labels are the labels that you see next to each line. Use the
RTickLabels
property to specify the associated labels.
Example: ax.RTick = [0 2 4 6];
Alternatively, use the rticks
function to specify the tick
values.
RColor
— Color of r-axis
[0.15 0.15 0.15]
(default) | RGB triplet | hexadecimal color code | 'r'
| 'g'
| 'b'
| ...
Color of the r-axis, including the r-axis grid lines, tick marks, and tick labels. Specify this value as an RGB triplet, a hexadecimal color code, a color name, or a short name.
Note
If you specify the GridColor
property, then the grid lines use
the color in the GridColor
property instead. See GridColorMode
for more
information.
For a custom color, specify an RGB triplet or a hexadecimal color code.
An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range
[0,1]
, for example,[0.4 0.6 0.7]
.A hexadecimal color code is a string scalar or character vector that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. The values are not case sensitive. Therefore, the color codes"#FF8800"
,"#ff8800"
,"#F80"
, and"#f80"
are equivalent.
Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"red" | "r" | [1 0 0] | "#FF0000" | |
"green" | "g" | [0 1 0] | "#00FF00" | |
"blue" | "b" | [0 0 1] | "#0000FF" | |
"cyan"
| "c" | [0 1 1] | "#00FFFF" | |
"magenta" | "m" | [1 0 1] | "#FF00FF" | |
"yellow" | "y" | [1 1 0] | "#FFFF00" | |
"black" | "k" | [0 0 0] | "#000000" | |
"white" | "w" | [1 1 1] | "#FFFFFF" | |
"none" | Not applicable | Not applicable | Not applicable | No color |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[0 0.4470 0.7410] | "#0072BD" | |
[0.8500 0.3250 0.0980] | "#D95319" | |
[0.9290 0.6940 0.1250] | "#EDB120" | |
[0.4940 0.1840 0.5560] | "#7E2F8E" | |
[0.4660 0.6740 0.1880] | "#77AC30" | |
[0.3010 0.7450 0.9330] | "#4DBEEE" | |
[0.6350 0.0780 0.1840] | "#A2142F" |
For example, ax.RColor = 'r'
changes the color to red.
Version History
Introduced in R2016aR2022a: Tick values display with degree symbols by default
Polar axes now display tick values in degrees with degree symbols when the
ThetaAxisUnits
property is set to
"degrees"
.
This change clarifies which units are being used for the theta
tick values. You can use the ThetaAxisUnits
property to display
the tick values in degrees or radians. To remove the degree symbols, change the tick
label format for the
theta-axis:
pax = polaraxes;
pax.ThetaAxis.TickLabelFormat = "%g";
See Also
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)