Scatter chart in polar coordinates
polarscatter(___,
sets
the marker symbol. For example, mkr
)'+'
displays cross
markers. Specify the marker symbol after any of the input argument
combinations in the previous syntaxes.
polarscatter(___,'filled')
fills
the marker interiors.
polarscatter(___,
modifies
the appearance of the scatter plot using one or more name-value pair
arguments. For example, you can use semi-transparent markers by specifying Name,Value
)'FaceAlpha'
and
a scalar value between 0
and 1
.
polarscatter(
plots
into the polar axes specified by pax
,___)pax
instead of
into the current axes.
returns
the ps
= polarscatter(___)Scatter
object. Use ps
to
modify the appearance of the Scatter
object after
it is created. For a list of properties, see Scatter Properties.
Create a scatter chart in polar coordinates.
th = pi/4:pi/4:2*pi; r = [19 6 12 18 16 11 15 15]; polarscatter(th,r)
Create a scatter chart that uses filled markers by specifying the optional input argument, 'filled'
. Set the marker size to 75 points squared.
th = linspace(0,2*pi,20);
r = rand(1,20);
sz = 75;
polarscatter(th,r,sz,'filled')
Create a scatter chart with markers of varying sizes and colors. Specify the optional size and color input arguments as vectors. Use unique values in the color vector to specify the different colors you want. The values map to colors in the colormap.
th = pi/4:pi/4:2*pi; r = [19 6 12 18 16 11 15 15]; sz = 100*[6 15 20 3 15 3 6 40]; c = [1 2 2 2 1 1 2 1]; polarscatter(th,r,sz,c,'filled','MarkerFaceAlpha',.5)
Create data where the angle values are in degrees. Since polarscatter
requires angle values in radians, convert the values to radians before plotting using deg2rad
.
th = linspace(0,360,50); r = 0.005*th/10; th_radians = deg2rad(th); polarscatter(th_radians,r)
Combine two scatter charts in the same polar axes using the hold
command. Add a legend with a description of each chart.
th = pi/6:pi/6:2*pi; r1 = rand(12,1); polarscatter(th,r1,'filled') hold on r2 = rand(12,1); polarscatter(th,r2,'filled') hold off legend('Series A','Series B')
Create a scatter chart and assign the scatter object to the variable ps
.
th = pi/6:pi/6:2*pi;
r = rand(12,1);
ps = polarscatter(th,r,'filled')
ps = Scatter with properties: Marker: 'o' MarkerEdgeColor: 'none' MarkerFaceColor: 'flat' SizeData: 36 LineWidth: 0.5000 ThetaData: [1x12 double] RData: [1x12 double] ZData: [1x0 double] CData: [0 0.4470 0.7410] Show all properties
Use ps
to modify properties of the scatter object after it is created.
ps.Marker = 'square'; ps.SizeData = 200; ps.MarkerFaceColor = 'red'; ps.MarkerFaceAlpha = .5;
th
— theta valuestheta values, specified as a vector or a
scalar in radians. th
and r
must
be the same size. To convert degrees to radians, use deg2rad
.
The ThetaData
property of the scatter object
stores the theta values.
Example: th = [3 2 4 5 7 2 3];
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
r
— rho valuesrho values, specified as a vector or a scalar. th
and r
must
be the same size.
The RData
property of the scatter object
stores the rho values.
Example: r = 0:pi/2:2*pi;
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
sz
— Marker sizes in points squared36
(default) | scalar | vector | []
Marker sizes in points squared, specified in one of these forms:
Scalar — Uniform marker size. For example, sz
= 100
creates all markers with an area of 100 points squared.
Vector — Different marker size for each data
point. The vector must be the same length as th
and r
.
Empty brackets []
— Default
marker size with an area of 36 points squared. Use this option if
you want to specify the color input argument, but use the default
marker area; for example, polarscatter(th,r,[],c)
.
The SizeData
property of the scatter object
stores the marker sizes.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
c
— Marker colors'r'
'g'
'b'
| ...Marker colors, specified in one of these forms.
RGB triplet or color name — Uniform marker color, such
as 'red'
.
Vector — Different marker colors for each data point.
The values in c
are linearly mapped to colors
in the colormap. The vector must be the same length as
th
and r
.
Three-column matrix of RGB triplets — Different marker
colors for each data point using RGB triplet colors. The length
of the matrix must be the same length as th
and r
.
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.
Option | Description | Equivalent 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] |
When you specify the marker colors, polarscatter
sets
the MarkerFaceColor
property of the scatter object to
'flat'
and stores the marker colors in the CData
property.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| char
| string
mkr
— Marker symbol'o'
(default) | '+'
| '*'
| '.'
| 'x'
| 's'
| ...Marker symbol, specified as one of the marker symbols listed in this table.
Value | Description |
---|---|
'o' | Circle |
'+' | Plus sign |
'*' | Asterisk |
'.' | Point |
'x' | Cross |
'_' | Horizontal line |
'|' | Vertical line |
'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 |
The Marker
property of the scatter object
stores the marker symbol.
pax
— PolarAxes
objectPolarAxes
objectPolarAxes
object. If you do not specify the
polar axes, then polarscatter
uses the current
axes. polarscatter
does not support plotting into
Cartesian axes.
Specify optional
comma-separated pairs of Name,Value
arguments. Name
is
the argument name and Value
is the corresponding value.
Name
must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN
.
polarscatter(th,r,'filled','MarkerFaceAlpha',.5)
creates
filled, semi-transparent markers.The scatter object properties listed here are only a subset. For a complete list, see Scatter Properties.
'MarkerFaceAlpha'
— Marker face transparency1
(default) | scalar in range [0,1]
Marker face transparency, specified as a scalar in the range [0,1]
.
A value of 1 is opaque and 0 is transparent. Values between 0 and
1 are semi-transparent.
'MarkerEdgeColor'
— Marker outline color'flat'
(default) | RGB triplet | hexadecimal color code | 'r'
| 'g'
| 'b'
| ...Marker outline color, specified 'flat'
, an RGB triplet, a hexadecimal color
code, a color name, or a short name. The default value of 'flat'
uses
colors from the CData
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 character vector or a string
scalar 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. Thus, 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' |
Example: [0.5 0.5 0.5]
Example: 'blue'
Example: '#D2F9A7'
'MarkerFaceColor'
— Marker fill color'none'
(default) | 'flat'
| 'auto'
| RGB triplet | hexadecimal color code | 'r'
| 'g'
| 'b'
| ...Marker fill color, specified as 'flat'
, 'auto'
, an RGB
triplet, a hexadecimal color code, a color name, or a short name. The
'flat'
option uses the CData
values. The
'auto'
option uses the same color as the Color
property for the axes.
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 character vector or a string
scalar 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. Thus, 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' |
Example: [0.3 0.2 0.1]
Example: 'green'
Example: '#D2F9A7'
'LineWidth'
— Width of marker edge0.5
(default) | positive valueWidth of marker edge, specified as a positive value in point units.
Example: 0.75
You have a modified version of this example. Do you want to open this example with your edits?