Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

polarplot

Plot line in polar coordinates

Syntax

polarplot(theta,rho)
polarplot(theta,rho,LineSpec)
polarplot(theta1,rho1,...,thetaN,rhoN)
polarplot(theta1,rho1,LineSpec1,...,thetaN,rhoN,LineSpec1)
polarplot(rho)
polarplot(rho,LineSpec)
polarplot(Z)
polarplot(Z,LineSpec)
polarplot(___,Name,Value)
polarplot(pax,___)
p = polarplot(___)

Description

example

polarplot(theta,rho) plots a line in polar coordinates, with theta indicating the angle in radians and rho indicating the radius value for each point. The inputs must be vectors with equal length or matrices with equal size. If the inputs are matrices, then polarplot plots columns of rho versus columns of theta. Alternatively, one of the inputs can be a vector and the other a matrix as long as the vector is the same length as one dimension of the matrix.

example

polarplot(theta,rho,LineSpec) sets the line style, marker symbol, and color for the line.

polarplot(theta1,rho1,...,thetaN,rhoN) plots multiple rho,theta pairs.

polarplot(theta1,rho1,LineSpec1,...,thetaN,rhoN,LineSpec1) specifies the line style, marker symbol, and color for each line.

example

polarplot(rho) plots the radius values in rho at evenly spaced angles between 0 and 2π.

polarplot(rho,LineSpec) sets the line style, marker symbol, and color for the line.

example

polarplot(Z) plots the complex values in Z.

polarplot(Z,LineSpec) sets the line style, marker symbol, and color for the line.

polarplot(___,Name,Value) specifies properties of the chart line using one or more Name,Value pair arguments. The property settings apply to all the lines. You cannot specify different property values for different lines using Name,Value pairs.

polarplot(pax,___) uses the PolarAxes object specified by pax, instead of the current axes.

example

p = polarplot(___) returns one or more chart line objects. Use p to set properties of a specific chart line object after it is created. For a list of properties, see Line Properties.

Examples

collapse all

Plot a line in polar coordinates.

theta = 0:0.01:2*pi;
rho = sin(2*theta).*cos(2*theta);
polarplot(theta,rho)

Create the data to plot.

theta = linspace(0,360,50);
rho = 0.005*theta/10;

Convert the values in theta from degrees to radians. Then, plot the data in polar coordinates.

theta_radians = deg2rad(theta);
polarplot(theta_radians,rho)

Plot two lines in polar coordinates. Use a dashed line for the second line.

theta = linspace(0,6*pi);
rho1 = theta/10;
polarplot(theta,rho1)

rho2 = theta/12;
hold on
polarplot(theta,rho2,'--')
hold off

Specify only the radius values, without specifying the angle values. polarplot plots the radius values at equally spaced angles that span from 0 to . Display a circle marker at each data point.

rho = 10:5:70;
polarplot(rho,'-o')

Create a polar plot using negative radius values. By default, polarplot reflects negative values through the origin.

theta = linspace(0,2*pi);
rho = sin(theta);
polarplot(theta,rho)

Change the limits of the r-axis so it ranges from -1 to 1.

rlim([-1 1])

Create a polar plot using a red line with circle markers.

theta = linspace(0,2*pi,25);
rho = 2*theta;
polarplot(theta,rho,'r-o')

Create a polar plot and return the chart line object.

theta = linspace(0,2*pi,25);
rho = 2*theta;
p = polarplot(theta,rho);

Change the line color and width and add markers.

p.Color = 'magenta';
p.Marker = 'square';
p.MarkerSize = 8;

Plot complex values in polar coordinates. Display markers at each point without a line connecting them.

Z = [2+3i 2 -1+4i 3-4i 5+2i -4-2i -2+3i -2 -3i 3i-2i];
polarplot(Z,'*')

Input Arguments

collapse all

Angle values, specified as a vector or matrix. Specify the values in radians. To convert data from degrees to radians, use deg2rad.

To change the limits of the theta-axis, use thetalim.

Example: [0 pi/2 pi 3*pi/2 2*pi]

Radius values, specified as a vector or matrix. By default, negative values are reflected through 0. A point is reflected by taking the absolute value of its radius, and adding 180 degrees to its angle.

To change the limits of the r-axis, use rlim.

Example: [1 2 3 4 5]

Complex values, specified as a vector or matrix where each element is of the form rho*ei*theta, or x+iy, where:

  • rho = sqrt(x^2+y^2)

  • theta = atan(y/x)

Example: [1+2i 3+4i 3i]

Line specification, specified as a character vector or string containing a line style, marker, and color specifier. The elements can appear in any order, and you can omit one or more options. If you omit the line style and specify the marker, then the plot shows only markers with no line connecting them.

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

SpecifierLine Style
-Solid line (default)
--Dashed line
:Dotted line
-.Dash-dot line
SpecifierMarker
oCircle
+Plus sign
*Asterisk
.Point
xCross
sSquare
dDiamond
^Upward-pointing triangle
vDownward-pointing triangle
>Right-pointing triangle
<Left-pointing triangle
pPentagram
hHexagram
SpecifierColor

y

yellow

m

magenta

c

cyan

r

red

g

green

b

blue

w

white

k

black

PolarAxes object. You can modify the appearance and behavior of a PolarAxes object by setting its properties. For a list of properties, see PolarAxes Properties.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'LineWidth',3

Name,Value pair settings apply to all the lines plotted. You cannot specify different Name,Value pairs for each line using this syntax. Instead, return the chart line objects and use dot notation to set the properties for each line.

The properties listed here are only a subset. For a full list, see Line Properties.

collapse all

Line color, specified as an RGB triplet or one of the color options listed in the table.

For a custom color, specify an RGB triplet. 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]. Alternatively, you can specify some common colors by name. This table lists the long and short color name options and the equivalent RGB triplet values.

OptionDescriptionEquivalent RGB Triplet
'red' or 'r'Red[1 0 0]
'green' or 'g'Green[0 1 0]
'blue' or 'b'Blue[0 0 1]
'yellow' or 'y'Yellow[1 1 0]
'magenta' or 'm'Magenta[1 0 1]
'cyan' or 'c'Cyan[0 1 1]
'white' or 'w'White[1 1 1]
'black' or 'k'Black[0 0 0]
'none'No colorNot applicable

Line style, specified as one of the line styles listed in this table.

Line StyleDescriptionResulting Line
'-'Solid line

'--'Dashed line

':'Dotted line

'-.'Dash-dotted line

'none'No lineNo line

Line width, specified as a positive value in points. If the line has markers, then the line width also affects the marker edges.

Example: 0.75

Marker symbol, specified as one of the markers in this table. By default, a chart line does not have markers. Add markers at each data point along the line by specifying a marker symbol.

ValueDescription
'o'Circle
'+'Plus sign
'*'Asterisk
'.'Point
'x'Cross
'square' or 's'Square
'diamond' or 'd'Diamond
'^'Upward-pointing triangle
'v'Downward-pointing triangle
'>'Right-pointing triangle
'<'Left-pointing triangle
'pentagram' or 'p'Five-pointed star (pentagram)
'hexagram' or 'h'Six-pointed star (hexagram)
'none'No markers

Marker size, specified as a positive value in points.

Example: 10

Marker fill color, specified as 'auto', an RGB triplet, or one of the color options listed in the table. The 'auto' value uses the same color as the Color property for the axes.

For a custom color, specify an RGB triplet. 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]. Alternatively, you can specify some common colors by name. This table lists the long and short color name options and the equivalent RGB triplet values.

OptionDescriptionEquivalent RGB Triplet
'red' or 'r'Red[1 0 0]
'green' or 'g'Green[0 1 0]
'blue' or 'b'Blue[0 0 1]
'yellow' or 'y'Yellow[1 1 0]
'magenta' or 'm'Magenta[1 0 1]
'cyan' or 'c'Cyan[0 1 1]
'white' or 'w'White[1 1 1]
'black' or 'k'Black[0 0 0]
'none'No colorNot applicable

Example: [0.3 0.2 0.1]

Example: 'green'

Tips

  • To convert data from degrees to radians, use deg2rad. To convert data from radians to degrees, use rad2deg.

  • You can modify polar axes properties to customize the chart. For a list of properties, see PolarAxes Properties.

  • To plot additional data in the polar axes, use the hold on command. However, you cannot plot data that requires Cartesian axes in a polar chart.

See Also

Functions

Properties

Introduced in R2016a

Was this topic helpful?