This topic describes some common tasks you can perform using geographic bubble charts properties.
You can use the size of the bubbles in a geographic bubble chart to communicate a quantifiable aspect of your data. For example, for Lyme disease sample data, you can use bubble size to visualize the number of cases in each county in New England. The following properties of the geographic bubble chart work together to control the size of the bubbles on the chart:
SizeData
SizeVariable
SizeLimits
BubbleWidthRange
The SizeData
property specifies the data that you want to plot
on the chart. SizeData
must be a vector of numeric data the same
size as the latitude and longitude vectors, or a scalar. Another way to specify size
data is to pass a table as the first argument to geobubble
and
specify the name of a table variable to use for size data. You use the
SizeVariable
property to specify this table variable. When
you use a table variable to specify size data, geobubble
stores
the values of this variable in the SizeData
property and sets the
property to read-only. If you do not specify SizeData
,
geobubble
plots the geographic locations on a map using
bubbles that are all the same size.
geobubble
determines the size (diameter) of each bubble by
linearly scaling the SizeData
values between the limits set by
the BubbleWidthRange
property.
BubbleWidthRange
is a two-element vector that specifies the
smallest bubble diameter and the largest bubble diameter in points. By default,
BubbleWidthRange
sets the range of bubble diameters between 5
points and 20 points. You can specify a bubble diameter as small as 1 point and as
large as 100 points.
Use the SizeLimits
property to control the mapping between
SizeData
and BubbleWidthRange
. By default,
the SizeLimits
property specifies the extremes of your data
range. For example, the SizeLimits
default for the Lyme disease
sample data is: [0 514]
when the Cases2010 variable is used as
the SizeVariable
.
When you specify size data, the geographic bubble chart includes a legend that
describes the mapping of bubble sizes to your data. geobubble
uses the values in the SizeLimits
property as upper and lower
bounds of the legend. When you specify a table variable,
geobubble
uses the variable name as the title of the size
legend.
This example shows how to reduce the size of the bubbles in a geographic bubble chart using the BubbleWidthRange
property. (You can also reduce overlapping by resizing the geographic bubble chart figure.)
Read Lyme disease sample data into the workspace.
counties = readtable('counties.xlsx');
Create a geographic bubble chart using the latitude, longitude, and occurrence data from the table. Adjust the limits of the chart using the geolimits
function.
gb = geobubble(counties,'Latitude','Longitude','SizeVariable','Cases2010'); geolimits(gb,[41 47],[-75 -66])
View the values of the SizeData
and SizeLimits
properties of the geographic bubble chart.
size_data_values = gb.SizeData; size_data_values(1:15)
ans = 15×1
331
187
88
125
240
340
161
148
38
4
⋮
size_limits = gb.SizeLimits
size_limits = 1×2
0 514
Make the bubbles smaller to avoid overlapping using the BubbleWidthRange
property. First view the initial setting of the property.
default_width_range = gb.BubbleWidthRange
default_width_range = 1×2
5 20
gb.BubbleWidthRange = [4 15];
You can use the color of the bubbles in a geographic bubble chart to code them according to data category. For example, in the Lyme disease sample data, you can characterize the severity of Lyme disease in each county in New England as high, medium, or low. The following properties of the geographic bubble chart work together to control the color of the bubbles on the chart:
ColorData
ColorVariable
BubbleColorList
The ColorData
property specifies the data that you want to
control the color of the bubbles in your chart. ColorData
must be
a vector of categorical data, the same size as latitude and longitude. Another way
to specify color data is to pass a table as the first argument to
geobubble
and specify the name of a table variable to use for
color data. You use the ColorVariable
property to specify this
table variable. geobubble
stores the values of the table variable
in the ColorData
property and sets the property to
read-only.
If your data does not initially include a categorical
variable,
you can create one. For example, the Lyme disease sample data does not include a
categorical variable. One way to create a variable of this type is to use the
discretize
function. Take the occurrences data,
cases2010
, and create three categories based on the number of
occurrences, describing them as low, medium, or high. The following code creates a
categorical variable named Severity
from the occurrence
data.
Severity = discretize(counties.Cases2010,[0 50 100 550],... 'categorical', {'Low', 'Medium', 'High'});
The BubbleColorList
property controls the colors used for the
bubbles in a geographic bubble chart. The value is an m-by-3
array where each row is an RGB color triplet. By default,
geobubble
uses a set of seven colors. If you have more than
seven categories, the colors repeat cyclically. To change the colors used, use one
of the other MATLAB® colormap functions, such as parula
or
jet
, or specify a custom list of colors.
discretize
| geobubble
| GeographicBubbleChart Properties | geolimits