Main Content

polar

(Not recommended) Polar coordinate plot

polar is not recommended. Use polarplot instead. For information on updating your code, see Version History.

Description

polar(theta,rho) plots a line in polar coordinates, with theta indicating the angle in radians and rho indicating the radius value for each point. theta and rho must be the same size.

polar(theta,rho,LineSpec) specifies the line style, marker symbol, and color for the lines drawn in the polar plot.

example

polar(ax,___) plots into the specified axes instead of the current axes (gca).

ln = polar(___) returns the Line object used to create the polar plot. Use ln to modify the polar plot after it is created. For a list of properties, see Line Properties.

Examples

collapse all

Create a polar plot using a dashed red line.

theta = 0:0.01:2*pi;
rho = sin(2*theta).*cos(2*theta);
polar(theta,rho,"--r")

Figure contains an axes object. The hidden axes object contains an object of type line.

Input Arguments

collapse all

Angle values, specified as a vector or matrix. Specify the values in radians.

Radius values, specified as a vector or matrix.

Negative rho values reflect through the origin, rotating by pi (since (theta,rho) transforms to (rho*cos(theta),rho*sin(theta))). If you want different behavior, you can manipulate rho prior to plotting. For example, you can set rho equal to max(0,rho) or abs(rho).

Line style, marker, and color, specified as a string scalar or character vector containing symbols. The symbols can appear in any order. You do not need to specify all three characteristics (line style, marker, and color). For example, if you omit the line style and specify the marker, then the plot shows only the marker and no line.

Example: "--or" is a red dashed line with circle markers.

Line StyleDescriptionResulting Line
"-"Solid line

Sample of solid line

"--"Dashed line

Sample of dashed line

":"Dotted line

Sample of dotted line

"-."Dash-dotted line

Sample of dash-dotted line, with alternating dashes and dots

MarkerDescriptionResulting Marker
"o"Circle

Sample of circle marker

"+"Plus sign

Sample of plus sign marker

"*"Asterisk

Sample of asterisk marker

"."Point

Sample of point marker

"x"Cross

Sample of cross marker

"_"Horizontal line

Sample of horizontal line marker

"|"Vertical line

Sample of vertical line marker

"square"Square

Sample of square marker

"diamond"Diamond

Sample of diamond marker

"^"Upward-pointing triangle

Sample of upward-pointing triangle marker

"v"Downward-pointing triangle

Sample of downward-pointing triangle marker

">"Right-pointing triangle

Sample of right-pointing triangle marker

"<"Left-pointing triangle

Sample of left-pointing triangle marker

"pentagram"Pentagram

Sample of pentagram marker

"hexagram"Hexagram

Sample of hexagram marker

Color NameShort NameRGB TripletAppearance
"red""r"[1 0 0]

Sample of the color red

"green""g"[0 1 0]

Sample of the color green

"blue""b"[0 0 1]

Sample of the color blue

"cyan" "c"[0 1 1]

Sample of the color cyan

"magenta""m"[1 0 1]

Sample of the color magenta

"yellow""y"[1 1 0]

Sample of the color yellow

"black""k"[0 0 0]

Sample of the color black

"white""w"[1 1 1]

Sample of the color white

Target axes, specified as an Axes object. If you do not specify the axes, MATLAB® plots into the current axes or it creates an Axes object if one does not exist. polar does not support plotting into PolarAxes objects.

Extended Capabilities

Version History

Introduced before R2006a

collapse all

R2016a: Not recommended

polar is not recommended. Use polarplot instead. There are no plans to remove polar.

The polarplot function draws one or more chart lines in a PolarAxes object, which has more relevant customization options than the Axes object used in polar. For example, you can change the units of the polar plot by setting the ThetaAxisUnits property of the PolarAxes object.

This table shows some typical uses of polar and how to update your code to use polarplot instead.

ObjectiveNot RecommendedRecommendedDifferences
Plot multiple lines on the same axes.
figure
hold on
polar(theta1,rho1)
...
polar(thetaN,rhoN)
polarplot(theta1,rho1,...,thetaN,rhoN)
  • polar accepts only one pair of theta and rho inputs.

  • polarplot accepts one or more pairs of theta and rho inputs.

Specify the plot appearance.
polar(theta,rho,LineSpec)
polarplot(theta,rho,LineSpec)

or

polarplot(theta,rho,Name,Value)
  • polar accepts the LineSpec input argument to set the line style, marker symbol, and color of the plotted line.

  • polarplot accepts either the LineSpec input argument to set the line style, marker symbol, and color of the plotted lines, or name-value arguments to set any properties of the plotted lines. For a list of properties, see Line Properties.

Specify the target axes.
polar(ax,__)
polarplot(pax,__)
  • polar accepts an Axes target axes.

  • polarplot accepts a PolarAxes target axes.