Main Content

# fpolarplot

Plot expression or function in polar coordinates

Since R2024a

## Syntax

``fpolarplot(f)``
``fpolarplot(f,[a b])``
``fpolarplot(___,LineSpec)``
``fpolarplot(___,Name=Value)``
``fpolarplot(pax,___)``
``fp = fpolarplot(___)``

## Description

example

````fpolarplot(f)` plots the curve defined by the expression or function `r = f(theta)` in polar coordinates over the default interval `0 ≤ theta ≤ 2π`.```

example

````fpolarplot(f,[a b])` plots `r = f(theta)` over the specified interval ```a ≤ theta ≤ b```.```

example

````fpolarplot(___,LineSpec)` specifies the line style, marker symbol, and line color. For example, `"-r"` plots a solid red line. Use this option after any of the input argument combinations in the previous syntaxes.```

example

````fpolarplot(___,Name=Value)` specifies line properties using one or more name-value arguments. For example, `LineWidth=2` specifies a line width of 2 points.```
````fpolarplot(pax,___)` plots into the `PolarAxes` object specified by `pax` instead of the current axes (`gca`).```

example

````fp = fpolarplot(___)` returns a `FunctionLine` object. Use the object to query and modify properties of the plotted line. For a list of properties, see FunctionLine Properties.```

## Examples

collapse all

Create a polar plot of the expression $1+\mathrm{cos}\left(\theta \right)$ over the interval $0\le \theta \le 2\pi$.

```f = @(t) 1 + cos(t); fpolarplot(f)```

Plot ${\mathit{t}}^{2}$ over the interval $-2\pi \le t\le 2\pi$ by specifying the plotting interval as the second input to `fpolarplot`.

```f = @(t) t.^2; fpolarplot(f,[-2*pi 2*pi])```

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

```f = @(t) sin(t); fpolarplot(f)```

Change the limits of the $\mathit{r}$-axis so it ranges from –1 to 1.

`rlim([-1 1])`

Plot three curves in polar coordinates. Use a dash-dotted line for the first curve, a dashed line with a line width of 2 for the second curve, and a solid blue line for the third curve.

```fpolarplot(@(t) t.^(1/4),"-.") hold on fpolarplot(@(t) t.^(2/3),"--",LineWidth=2) fpolarplot(@(t) t,"-b") legend hold off```

Plot the curve $\mathit{r}=\mathrm{sin}\left(2\theta \right)\text{\hspace{0.17em}}\mathrm{cos}\left(2\theta \right)$ in polar coordinates, and return the function line object.

```f = @(t) sin(2*t).*cos(2*t); fp = fpolarplot(f)```

```fp = FunctionLine with properties: Function: @(t)sin(2*t).*cos(2*t) Color: [0 0.4470 0.7410] LineStyle: '-' LineWidth: 0.5000 Use GET to show all properties ```

You can access and modify properties of the function line object by using dot notation. For example, change the color, line style, and line width.

```fp.Color = "r"; fp.LineStyle = ":"; fp.LineWidth = 2;```

## Input Arguments

collapse all

Function to plot, specified as a function handle to a named or anonymous function.

Specify a function of the form `r = f(theta)`. The function must accept a vector input argument and return a vector output argument of the same size. Use array operators instead of matrix operators for the best performance. For example, use `.*` (`times`) instead of * (`mtimes`).

Example: `fpolarplot(@(theta) theta.*sin(theta))` plots `theta.*sin(theta)` over the default interval, ```[0 2*pi]```.

Interval for the polar angle `theta`, specified as a two-element vector of the form `[a b]`. `fpolarplot` plots over the specified interval `a ≤ theta ≤ b`.

`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.

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

`"--"`Dashed line

`":"`Dotted line

`"-."`Dash-dotted line

MarkerDescriptionResulting Marker
`"o"`Circle

`"+"`Plus sign

`"*"`Asterisk

`"."`Point

`"x"`Cross

`"_"`Horizontal line

`"|"`Vertical line

`"square"`Square

`"diamond"`Diamond

`"^"`Upward-pointing triangle

`"v"`Downward-pointing triangle

`">"`Right-pointing triangle

`"<"`Left-pointing triangle

`"pentagram"`Pentagram

`"hexagram"`Hexagram

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

`"green"``"g"``[0 1 0]`

`"blue"``"b"``[0 0 1]`

`"cyan"` `"c"``[0 1 1]`

`"magenta"``"m"``[1 0 1]`

`"yellow"``"y"``[1 1 0]`

`"black"``"k"``[0 0 0]`

`"white"``"w"``[1 1 1]`

### 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.

Example: `fpolarplot(f,Marker="o",MarkerFaceColor="red")`

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

Line color, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name.

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 from `0` to `F`. 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 NameShort NameRGB TripletHexadecimal Color CodeAppearance
`"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"`

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
`[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"`

Example: `"blue"`

Example: ```[0 0 1]```

Example: `"#0000FF"`

Line style, specified as one of the options 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, where 1 point = 1/72 of an inch. If the line has markers, then the line width also affects the marker edges.

The line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.

Marker symbol, specified as one of the values listed in this table. By default, the object does not display markers. Specifying a marker symbol adds markers at each data point or vertex.

MarkerDescriptionResulting Marker
`"o"`Circle

`"+"`Plus sign

`"*"`Asterisk

`"."`Point

`"x"`Cross

`"_"`Horizontal line

`"|"`Vertical line

`"square"`Square

`"diamond"`Diamond

`"^"`Upward-pointing triangle

`"v"`Downward-pointing triangle

`">"`Right-pointing triangle

`"<"`Left-pointing triangle

`"pentagram"`Pentagram

`"hexagram"`Hexagram

`"none"`No markersNot applicable

Marker outline color, specified as `"auto"`, an RGB triplet, a hexadecimal color code, a color name, or a short name. The default value of `"auto"` uses the same color as the `Color` property.

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 from `0` to `F`. 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 NameShort NameRGB TripletHexadecimal Color CodeAppearance
`"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 applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
`[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"`

Marker fill color, specified as `"auto"`, an RGB triplet, a hexadecimal color code, a color name, or a short name. The `"auto"` value uses the same color as the `MarkerEdgeColor` property.

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 from `0` to `F`. 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 NameShort NameRGB TripletHexadecimal Color CodeAppearance
`"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 applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
`[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"`

Example: `[0.3 0.2 0.1]`

Example: `"green"`

Example: `"#D2F9A7"`

Marker size, specified as a positive value in points, where 1 point = 1/72 of an inch.

## Version History

Introduced in R2024a