Filled circular region (annulus) in polar coordinates

Since R2024a

## Syntax

``radiusregion(r1,r2)``
``radiusregion(R)``
``radiusregion(___,Name=Value)``
``radiusregion(pax,___)``
``pr = radiusregion(___)``

## Description

````radiusregion(r1,r2)` creates a filled circular region, or annulus, between the two specified radii in the current (polar) axes. To create one filled region, specify `r1` and `r2` as scalars. To create multiple filled regions, specify `r1` and `r2` as vectors of the same length.```

example

````radiusregion(R)` specifies multiple regions as a matrix. To create n regions, specify `R` as a 2-by-n or n-by-2 matrix containing the inner and outer bounds for each region.```

example

````radiusregion(___,Name=Value)` specifies properties for the region using one or more name-value arguments. If you create multiple regions, the property values apply to all of the regions. Specify the name-value arguments after all other inputs. For example, create a yellow radius region using `radiusregion(5,10,FaceColor="yellow")`. For a list of properties, see PolarRegion Properties.```

example

````radiusregion(pax,___)` specifies the target polar axes for the filled region. Specify `pax` as the first argument in any of the previous syntaxes.```

example

````pr = radiusregion(___)` returns one or more `PolarRegion` objects. Use `pr` to set properties of the filled regions after creating them. For a list of properties, see PolarRegion Properties.```

example

## Examples

collapse all

Create a polar plot and add a radius region that has an inner boundary of `r=0.3` and an outer boundary of `r=0.5`.

```% Create polar plot theta = 0:0.01:2*pi; rho = sin(2*theta).*cos(2*theta); polarplot(theta,rho,LineWidth=1.5) % Create filled region r1 = 0.3; r2 = 0.5; radiusregion(r1,r2)```

Change the theta-axis units to radians by setting the `ThetaAxisUnits` property.

```pax = gca; pax.ThetaAxisUnits = "radians";```

Create three concentric filled regions by specifying the bounding radii as three-element vectors.

```r1 = [0.2 0.5 0.8]; r2 = [0.4 0.7 1]; radiusregion(r1,r2)```

Alternatively, specify one 2-by-3 matrix of radius values.

```figure R = [0.2 0.5 0.8; 0.4 0.7 1]; radiusregion(R)```

You can specify `PolarRegion` properties, such as face color and boundary line width and color, by specifying one or more name-value arguments when you call `radiusregion`. Alternatively, you can set properties of the `PolarRegion` object after creating it.

For example, create two green radius regions. Specify an output argument to store the `PolarRegion` objects so that you can modify them later.

```r1 = [0.2 0.8]; r2 = [0.4 1]; rr = radiusregion(r1,r2,FaceColor="g");```

Change the color of the outer region to a shade of purple by specifying the `FaceColor` property as a hexadecimal color code. Then display thick boundary lines around the inner region by setting the `EdgeColor` property to a value other than `"none"` and setting the `LineWidth` property to `1.5`.

```% Set color of outer region rr(2).FaceColor = "#5500FF"; % Set boundary color and line thickness rr(1).EdgeColor = "b"; rr(1).LineWidth = 1.5;```

Plot a blue and a red rose.

```theta = linspace(0,2*pi,200); rho1 = sin(2*theta).*cos(2*theta); rho2 = 2*sin(2*theta).*cos(2*theta); % Blue rose rose1 = polarplot(theta,rho1,LineWidth=1.5); hold on % Red rose rose2 = polarplot(theta,rho2,LineWidth=1.5);```

Create radius regions that highlight the tips of the rose petals.

```r1 = 0.4; r2 = 0.5; region1 = radiusregion(r1,r2); r3 = 0.8; r4 = 1; region2 = radiusregion(r3,r4);```

Match the color of each radius region to the corresponding rose by setting the `SeriesIndex` property of the region to the `SeriesIndex` property of the rose.

```region1.SeriesIndex = rose1.SeriesIndex; region2.SeriesIndex = rose2.SeriesIndex;```

To move a radius region on top of a plot, set the `Layer` property of the `PolarRegion` object to `"top"`. For example, plot a polar rose and add a radius region. When you create the radius region, specify a custom face color and transparency value so that you can see that the rose is on top of the radius region.

```% Plot polar rose theta = 0:0.01:2*pi; rho = sin(2*theta).*cos(2*theta); polarplot(theta,rho,LineWidth=1.5) % Add radius region r1 = 0.2; r2 = 0.3; rr = radiusregion(r1,r2,FaceColor=[0.8 0.8 0.8],FaceAlpha=0.7);```

Move the radius region on top of the rose by setting the `Layer` property to `"top"`.

`rr.Layer = "top";`

To create radius regions in different polar axes within the same figure, create a tiled chart layout. In this case, create two axes that each contain a radius region.

Use the `tiledlayout` function to create a 1-by-2 tiled chart layout `t`. Use the `polaraxes` function to create each `PolarAxes` object. By default, both objects occupy the first tile. Move the second `PolarAxes` object to the second tile by setting the `Layout.Tile` property.

```t = tiledlayout(1,2); pax1 = polaraxes(t); pax2 = polaraxes(t); pax2.Layout.Tile = 2;```

Create a red radius region in the first polar axes, and create a green radius region in the second polar axes. Specify the `PolarAxes` object that you want to plot into as the first argument when you call `radiusregion`.

```r1 = 0.2; r2 = 0.6; radiusregion(pax1,r1,r2,FaceColor="r") radiusregion(pax2,r1,r2,FaceColor="g")```

## Input Arguments

collapse all

Inner and outer radii, specified as a pair of scalars or a pair of vectors. To create one filled region, specify `r1` and `r2` as scalars. To create multiple filled regions, specify vectors of equal length. You can specify the radius values in any order. Thus, `radiusregion(1,5)` and `radiusregion(5,1)` produce the same result.

To create an unbounded region, specify one of the radii as `Inf`. Specifying a value of `–Inf` creates a filled circle centered at `r=0`.

If any radii are `NaN` values, no region appears for those radii.

Example: `radiusregion(0.5,1)` creates a filled region from `r=0.5` to `r=1`.

Example: `radiusregion([1 3],[2 4])` creates two filled regions: one from `r=1` to `r=2` and the other from `r=3` to `r=4`.

Data Types: `single` | `double`

Inner and outer radii for multiple regions, specified as a 2-by-n or n-by-2 matrix, where n is the number of regions. If you specify a 2-by-2 matrix, each column of the matrix corresponds to a region.

To create an unbounded region, specify one of the radii as `Inf`. Specifying a value of `–Inf` creates a filled circle centered at `r=0`.

If any radii are `NaN` values, no region appears for those radii.

Example: `radiusregion([1 3; 2 4])` creates a filled region from `r=1` to `r=2`, and another filled region from `r=3` to `r=4`.

Data Types: `single` | `double`

Target polar axes for the filled region, specified as a `PolarAxes` object. Use this argument if you want to create the filled region in a specific `PolarAxes` object instead of the current axes.

### 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: `radiusregion(0.5,1,FaceColor="yellow")` creates a yellow filled region.

Note

The properties listed here are only a subset. For a complete list, see PolarRegion Properties.

Fill color, specified as an RGB triplet, a hexadecimal color code, or a color 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"`

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

`[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"`

Boundary line color, specified as an RGB triplet, a hexadecimal color code, or a color 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"`

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

`[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"`

Fill color transparency, specified as a scalar in the range `[0,1]`. A value of `1` is opaque and `0` is completely transparent. Values between `0` and `1` are partially transparent.

Boundary 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

## Version History

Introduced in R2024a