Polar bubble chart
polarbubblechart(
specifies the colors of the bubbles. theta
,rho
,sz
,c
)
To use one color for all the bubbles, specify a color name, a hexadecimal color code, or an RGB triplet.
To assign a different color to each bubble, specify a vector the same length as
theta
and rho
. Alternatively, you can specify
a three-column matrix of RGB triplets. the number of rows in the matrix must match the
length of theta
and rho
.
polarbubblechart(___,
specifies Name,Value
)BubbleChart
properties using one or more name-value pair
arguments. Specify the properties after all other input arguments. For a list of properties,
see BubbleChart Properties.
polarbubblechart(
displays
the bubble chart in the target axes pax
,___)pax
. Specify the axes before all
other input arguments.
bc = polarbubblechart(___)
returns the
BubbleChart
object. Use bc
to modify properties of
the chart after creating it. For a list of properties, see BubbleChart Properties.
Define a set of bubble coordinates as the vectors th
and r
. Define sz
as a vector of bubble sizes. Then create a bubble chart of these values.
th = linspace(0,2*pi,10); r = rand(1,10); sz = rand(1,10); polarbubblechart(th,r,sz);
Define a set of bubble coordinates as the vectors th
and r
. Define sz
as a vector of bubble sizes. Then create a bubble chart and specify the color as red. By default, the bubbles are partially transparent.
th = 1:10;
r = rand(1,10);
sz = rand(1,10);
polarbubblechart(th,r,sz,'red');
For a custom color, you can specify an RGB triplet or a hexadecimal color code. For example, the hexadecimal color code '#7031BB'
, specifies a shade of purple.
polarbubblechart(th,r,sz,'#7031BB');
You can also specify a different color for each bubble. For example, specify a vector to select colors from the figure's colormap.
c = 1:10; polarbubblechart(th,r,sz,c)
Define a set of bubble coordinates as the vectors th
and r
. Define sz
as a vector of bubble sizes. Then create a bubble chart. By default, the bubbles are 60% opaque, and the edges are completely opaque with the same color.
th = linspace(0,2*pi,10); r = rand(1,10); sz = rand(1,10); polarbubblechart(th,r,sz);
You can customize the opacity and the outline color by setting the MarkerFaceAlpha
and MarkerEdgeColor
properties, respectively. One way to set a property is by specifying a name-value pair argument when you create the chart. For example, you can specify 20% opacity by setting the MarkerFaceAlpha
value to 0.20
.
bc = polarbubblechart(th,r,sz,'MarkerFaceAlpha',0.20);
If you create the chart by calling the polarbubblechart
function with a return argument, you can use the return argument to set properties on the chart after creating it. For example, you can change the outline color to purple.
bc.MarkerEdgeColor = [0.5 0 0.5];
Define a data set that shows the incoming air traffic at a certain airport over a certain period of time.
Define theta
as a vector of angles of approach for the incoming planes.
Define altitude
as a vector of altitudes.
Define planesize
as a vector of plane sizes, measured in the number of passengers.
Then display the data in a bubble chart with a bubble legend that shows the relationship between the bubble sizes and the number of passengers on the planes.
theta = repmat([0 pi/2 7*pi/6],1,4) + 0.25*randn(1,12); altitude = randi([13000 43000],1,12); planesize = randi([75 500],[1 12]); polarbubblechart(theta,altitude,planesize) bubblelegend('Number of Passengers','Location','eastoutside')
Define two data sets showing the incoming air traffic at two different airports over a certian period of time.
Define theta1
and theta2
as vectors containing the angles of approach for the incoming planes.
Define planesize1
and planesize2
as a vectors of plane sizes, measured in the number of passengers.
Define altitude1
and altitude2
as vectors containing the altitudes for the planes.
theta1 = repmat([0 pi/2 7*pi/6],1,4) + 0.25*randn(1,12); theta2 = repmat([pi pi/6 3*pi/2],1,4) + 0.25*randn(1,12); planesize1 = randi([75 500],[1 12]); planesize2 = randi([1 50],[1 12]); altitude1 = randi([13000 43000],1,12); altitude2 = randi([13000 85000],1,12);
Create a tiled chart layout so you can visualize the data side-by-side. Then, create a polar axes object in the first tile, plot the data for the first airport, and add a title. Then repeat the process in the second tile for the second airport.
t = tiledlayout(1,2); pax1 = polaraxes(t); polarbubblechart(pax1,theta1,altitude1,planesize1) title('Airport A') pax2 = polaraxes(t); pax2.Layout.Tile = 2; polarbubblechart(pax2,theta2,altitude2,planesize2); title('Airport B')
Reduce all the bubble sizes to make it easier to see all the bubbles. In this case, change the range of diameters to be between 5
and 20
points.
bubblesize(pax1,[5 20]) bubblesize(pax2,[5 20])
The planes at Airport A are generally much smaller than at Airport B, but the bubble sizes do not reflect this information in the preceding charts. This is because the smallest and largest bubbles map to the smallest and largest data points in each of the axes. To display the bubbles on the same scale, define a vector called allsizes
that includes the plane sizes at both airports. Then use the bubblelim
function to reset the scaling for both charts.
allsizes = [planesize1 planesize2]; newlims = [min(allsizes) max(allsizes)]; bubblelim(pax1,newlims) bubblelim(pax2,newlims)
theta
— theta valuestheta values, specified as a numeric scalar or vector the same
length as rho
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
rho
— rho valuesrho values, specified as a numeric scalar or vector the same
length as theta
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
sz
— Bubble sizesBubble sizes, specified as a numeric scalar or vector the same length as
theta
and rho
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
c
— Bubble color[0 0.4470 0.7410]
(default) | RGB triplet | color name | hexadecimal color code | three-column matrix of RGB triplets | vectorBubble color, specified as an RGB triplet, a color name, a hexadecimal color code, a matrix of RGB triplets, or a vector of colormap indices. You can display all the bubbles with the same color, or you can display each bubble with a different color. By default, the bubbles are filled with partially transparent color, and the edges of the bubbles are opaque.
Specify one of the following values to display all the bubbles with the same color:
RGB triplet — 1-by-3 row vector whose elements specify the intensities
of the red, green, and blue components of a color. The intensities must
be in the range [0,1]
; for example, [0.4 0.6
0.7]
.
Hexadecimal color code — 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.
Color name or short name — Color name or short name from the table below.
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' |
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' |
Specify one of the following values to assign a different color to each bubble:
Three-column matrix of RGB triplets — Each row of the matrix specifies
an RGB triplet color for the corresponding bubble. The values in each
row specify the intensities of the red, green, and blue components of
the color. The intensities must be in the range
[0,1]
. The number of rows must equal the length of
the coordinate vectors.
Vector of colormap indices — An m-by-1 vector of numbers that index
into the current colormap. The values in the vector cover the full range
of the colormap. The length of c
must equal the
length of the coordinate vectors. To change the colormap for the axes,
use the colormap
function.
pax
— Target axesPolarAxes
objectTarget axes, specified as a PolarAxes
object. If you do not
specify the axes, MATLAB plots into the current axes, or it creates a PolarAxes
object if one does not exist.
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
.
bubblechart([1 2 3],[4 10 9],[1 2 3],'MarkerFaceColor','red')
creates red bubbles.
Note
The properties listed here are only a subset. For a complete list, see BubbleChart Properties.
'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'flat'
(default) | 'auto'
| 'none'
| 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
'MarkerEdgeAlpha'
— Marker edge transparency1
(default) | scalar in range [0,1]
| 'flat'
Marker edge transparency, specified as a scalar in the range [0,1]
or 'flat'
. A value of 1 is opaque and 0 is completely transparent.
Values between 0 and 1 are semitransparent.
To set the edge transparency to a different value for each point in the plot, set the
AlphaData
property to a vector the same size as the
XData
property, and set the
MarkerEdgeAlpha
property to 'flat'
.
'MarkerFaceAlpha'
— Marker face transparency0.6
(default) | scalar in range [0,1]
| 'flat'
Marker face transparency, specified as a scalar in the range [0,1]
or 'flat'
. A value of 1 is opaque and 0 is completely transparent. Values between 0 and 1 are partially transparent.
To set the marker face transparency to a different value for each point, set the AlphaData
property to a vector the same size as the XData
property, and set the MarkerFaceAlpha
property to 'flat'
.
You have a modified version of this example. Do you want to open this example with your edits?