Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

geobubble

Visualize data values at specific geographic locations

Syntax

gb = geobubble(tbl,latvar,lonvar)
gb = geobubble(tbl,latvar,lonvar,Name,Value)
gb = geobubble(lat,lon)
gb = geobubble(lat,lon,sizedata)
gb = geobubble(lat,lon,sizedata,colordata)
gb = geobubble(___,Name,Value)
gb = geobubble(parent,___)

Description

gb = geobubble(tbl,latvar,lonvar) creates a geographic bubble chart with filled circles (“bubbles”) representing the geographic locations specified in the table tbl displayed on a map. latvar identifies the table variable (column) that specifies bubble latitudes. lonvar identifies the table variable that specifies bubble longitudes. By default, the bubbles are all the same size and the same color. The function returns gb, a GeographicBubbleChart object. To modify this object, use the properties described in GeographicBubbleChart Properties.

The geographic bubble chart displays your data on a map, called a basemap. Initially, the chart sets the geographic limits of the chart to encompass all of your data. The map is live, that is, you can pan the basemap to view other geographic locations. You can also zoom in and out on the map to view regions in more detail. The chart updates the map as you pan and zoom. For more information about geographic bubble charts and basemaps, see Geographic Bubble Charts Overview.

example

gb = geobubble(tbl,latvar,lonvar,Name,Value) uses additional options specified by one or more name-value pair arguments to set the values of geographic bubble chart properties. Two key properties are 'SizeVariable' and 'ColorVariable', which specify the table variables that determine the size and color of the bubbles.

gb = geobubble(lat,lon) creates a geographic bubble chart where lat and lon specify the geographic locations. By default, the bubbles are all the same size and color.

example

gb = geobubble(lat,lon,sizedata) scales the areas of the bubbles according to the numeric values in the sizedata vector.

example

gb = geobubble(lat,lon,sizedata,colordata) uses the categorical data in colordata to determine the color of the bubbles. geobubble chooses a color for each category in colordata, plus one additional color if any element of colordata is undefined. Colors are drawn from an ordered list of 7 standard colors. If there are more than seven categories (more than six, if undefined values are present), the colors repeat cyclically.

example

gb = geobubble(___,Name,Value) specifies additional options for the geographic bubble chart using one or more name-value pair arguments. Specify the options after all other input arguments. For a list of properties, see GeographicBubbleChart Properties.

gb = geobubble(parent,___) creates the geographic bubble chart in the figure, panel, or tab specified by parent.

Examples

collapse all

Read data about tsunamis into the workspace as a table. The rows represent individual tsunami occurrences. The columns represent data about a set of variables for each tsunami, such as their locations (latitude and longitude), causes, and wave heights.

tsunamis = readtable('tsunamis.xlsx');

Convert one of the table variables into a categorical variable to specify the color of the bubbles. The Cause variable attributes a cause to each tsunami, such as, 'Earthquake', 'Volcano', or 'Earthquake and Landslide'. Convert the Cause variable from a cell array of character vectors into a categorical variable.

tsunamis.Cause = categorical(tsunamis.Cause);

Create a geographic bubble chart, plotting the locations of the tsunamis on a map. Specify the names of the table variables that hold location information: Latitude and Longitude. Use the MaxHeight table variable to specify the size of the bubbles. The example uses the Cause variable, converted earlier into a categorical variable, to specify the color of the bubbles. Also specify the basemap.

gb = geobubble(tsunamis,'Latitude','Longitude', ...
    'SizeVariable','MaxHeight','ColorVariable','Cause')
gb = 
  GeographicBubbleChart with properties:

              Basemap: 'darkwater'
            MapLayout: 'normal'
          SourceTable: [162x20 table]
     LatitudeVariable: 'Latitude'
    LongitudeVariable: 'Longitude'
         SizeVariable: 'MaxHeight'
        ColorVariable: 'Cause'

  Show all properties

Read data about tsunamis into the workspace as a table. The rows represent individual tsunami occurrences. The columns represent data about a set of variables for each tsunami, such as their locations (latitude and longitude), causes, and wave heights.

tsunamis = readtable('tsunamis.xlsx');

Create a geographic bubble chart, plotting the locations of the tsunamis on a map. Use the data from the MaxHeight variable to specify the size of the bubble. In this example, you pass the data directly to geobubble. Alternatively, you can also pass geobubble the name of the table and then specify the data by table variable names.

gb = geobubble(tsunamis.Latitude,tsunamis.Longitude,tsunamis.MaxHeight)
gb = 
  GeographicBubbleChart with properties:

          Basemap: 'darkwater'
        MapLayout: 'normal'
     LatitudeData: [162x1 double]
    LongitudeData: [162x1 double]
         SizeData: [162x1 double]
        ColorData: []

  Show all properties

Read data about tsunamis into the workspace as a table. The rows represent individual tsunami occurrences. The columns represent data about each occurrence, such as the cause of each tsunami.

tsunamis = readtable('tsunamis.xlsx');

Create a categorical variable because the data that controls the color of the bubbles must be a categorical variable. The tsunami table variable Cause already categorizes the tsunamis by seven criteria: Earthquake, Earthquake and Landslide, Volcano, Volcano and Landslide, Landslide, Meteorological, and Unknown Cause. Put the Cause variable data into a categorical variable.

cause = categorical(tsunamis.Cause);

Create a geographic bubble chart, plotting the locations of the tsunamis on a map. Use bubble size to indicate the size of the wave, and use bubble color to indicate the cause. When you pass in the data, rather than specifying the names of table variables that contain the data, geobubble does not automatically add titles to the size and color legends.

gb = geobubble(tsunamis.Latitude,tsunamis.Longitude,tsunamis.MaxHeight,cause)
gb = 
  GeographicBubbleChart with properties:

          Basemap: 'darkwater'
        MapLayout: 'normal'
     LatitudeData: [162x1 double]
    LongitudeData: [162x1 double]
         SizeData: [162x1 double]
        ColorData: [162x1 categorical]

  Show all properties

Read data about tsunamis into the workspace as a table. The rows represent individual tsunami occurrences. The columns represent data about a set of variables for each tsunami, such as its location (latitude and longitude), cause, and maximum height of the wave.

tsunamis = readtable('tsunamis.xlsx');

Turn one of the table variables into a categorical variable to specify the color of the bubbles. The Cause variable attributes a cause to each tsunami, such as, 'Earthquake', 'Volcano', or 'Earthquake and Landslide'. Convert the Cause variable from a cell array of character vectors into a categorical variable.

colordata = categorical(tsunamis.Cause);

Create a geographic bubble chart, plotting the locations of the tsunamis on a map. Use bubble size to indicate the size of the wave, and use bubble color to indicate the cause of the tsunami. Also set the basemap and the title using name-value pair arguments.

gb = geobubble(tsunamis.Latitude,tsunamis.Longitude,tsunamis.MaxHeight,colordata,'Title','Tsunamis')
gb = 
  GeographicBubbleChart with properties:

          Basemap: 'darkwater'
        MapLayout: 'normal'
     LatitudeData: [162x1 double]
    LongitudeData: [162x1 double]
         SizeData: [162x1 double]
        ColorData: [162x1 categorical]

  Show all properties

Use properties of the geographic bubble chart to modify the chart. For example, add titles to the size and color legends. (If you specify the table as an argument, geobubble adds legend titles automatically, using the names of table variables.)

gb.SizeLegendTitle = 'Max Height';
gb.ColorLegendTitle = 'Cause'
gb = 
  GeographicBubbleChart with properties:

          Basemap: 'darkwater'
        MapLayout: 'normal'
     LatitudeData: [162x1 double]
    LongitudeData: [162x1 double]
         SizeData: [162x1 double]
        ColorData: [162x1 categorical]

  Show all properties

Input Arguments

collapse all

Table containing data to be plotted, specified as a table or timetable. You can import data as a table using the readtable function or create a table from workspace variables using the table function. You can create a timetable from workspace variables using the timetable function.

The SourceTable property of the GeographicBubbleChart object stores the table containing data to be plotted.

Data Types: table

Table variable for latitude, specified in one of these forms:

  • String scalar or character vector specifying one of the table variable names. For example, geobubble(tbl,'Latitude','Longitude') selects the variable named 'Latitude' for latvar.

  • Numeric scalar indicating the table variable index. For example, geobubble(tbl,1,2) selects the first variable in the table for latitude.

  • Logical vector containing one true element.

The LatitudeVariable property of the GeographicBubbleChart object stores the selected variable.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | string

Table variable for longitude, specified in one of these forms:

  • String scalar or character vector specifying one of the table variable names. For example, geobubble(tbl,'Latitude','Longitude') selects the variable named 'Longitude' for lonvar.

  • Numeric scalar indicating the table variable index. For example, geobubble(tbl,1,2) selects the second variable in the table for longitude.

  • Logical vector containing one true element.

The LongitudeVariable property of the GeographicBubbleChart object stores the selected variable.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | string

Latitude coordinates in degrees, specified as a real, numeric, finite vector within the range [-90 90]. The vector can contain embedded NaNs. lat must be the same size as lon.

Example: [43.0327 38.8921 44.0435]

Data Types: single | double

Longitude coordinates in degrees, specified as a real, numeric, finite vector. The vector can contain embedded NaNs. lon must be the same size as lat.

Example: [-107.5556 -77.0269 -72.5565]

Data Types: single | double

Data that determines bubble size, specified as a real, numeric, finite vector. sizedata must be the same size as lat and lon.

Example: [99 133 150]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Data categories that determine bubble color, specified as a categorical variable. The categories are typically bins that data fall into.

Data Types: categorical

Parent container in which to plot the geographic bubble chart, specified as a figure, panel, or tab object.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: p = geobubble(tbl,latvar,lonvar,'SizeVariable','MaxHeight','ColorVariable','Cause')

Note

The geographic bubble chart properties listed here are frequently used properties. For a complete list, see GeographicBubbleChart Properties.

collapse all

Map on which to plot data, specified as one of the string scalars or character vectors in the following table, or 'none'. By default, geobubble uses the 'darkwater' basemap, which is installed with the product. If you choose one of the other basemaps, geobubble accesses the map over the Internet. MathWorks® hosts these basemaps. If you do not have consistent access to the Internet, you can download these basemaps onto your local system. For more information about downloading basemaps, see Access Basemaps in MATLAB. If you specify 'none', geobubble plots your data, bubbles only, with latitude-longitude grid, ticks, and labels, but does not include a map.

Basemaps

Two-Tone BasemapsDescriptionNatural Earth BasemapsDescription

'darkwater' (default)

Land areas: light-to-moderate gray

Ocean and water areas: darker gray

'colorterrain'

Shaded relief map blended with a land cover palette. Humid lowlands are green and arid lowlands brown.

'grayland'

Land areas: light-to-moderate gray land

Ocean and water areas: white

'grayterrain'

Worldwide terrain depicted monochromatically in shades of gray, combining shaded relief that emphasizes both high mountains and the micro terrain found in lowlands.

'bluegreen'

Land areas: light green

Ocean and water areas: light blue

'landcover'

Satellite-derived land cover data and shaded relief presented with a light, natural palette suitable for making thematic and reference maps (includes ocean-bottom relief).

Example: gb = geobubble(__,'Basemap','bluegreen')

Example: gb.Basemap = 'bluegreen'

Data Types: char | string

Table variable used to determine bubble color, specified in one of these forms:

  • A string scalar or character vector specifying the name of the table variable you want to use for color information. For example, geobubble(__,'ColorVariable','Cause') specifies the variable named 'Cause'.

  • A numeric scalar indicating the table variable index. For example, geobubble(__,'ColorVariable',12) specifies the 12th variable in the table.

  • A logical vector containing one true element. For example, sizevar = logical([0 0 0 0 0 0 0 0 0 0 0 1]) specifies the 12th variable in the table.

You can use this property only when specifying a table as input. The values associated with this table variable must be categorical. When you specify the color variable, geobubble stores the data values associated with this variable in the ColorData property and sets the ColorData property to read-only.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | string

Layout of map, including insets and decorations, specified as either of the following.

ValueDescriptionIllustration
'normal'Map is inset from the edges of the chart, as defined by its OuterPosition property. Axes labels ('Latitude' and 'Longitude'), ticks, and tick labels are visible. If the Title property value is set, the chart includes a title. Legends, if present, appear outside and to the right of the map.
'maximized'Map fills the entire space, defined by the OuterPosition property. Axes labels, ticks, and tick labels are hidden. The title is hidden, even if the Title property is set. The grid is hidden, even if GridVisible is set to 'on'. Legends, if present, appear within the map, toward the upper-right corner.

Example: gb = geobubble(__,'MapLayout','maximized')

Example: gb.MapLayout = 'maximized'

Data Types: char | string

Table variable used to determine bubble size, specified in one of these forms:

  • A string scalar or character vector specifying the name of the table variable you want to use for size information. For example, geobubble(__,'SizeVariable','MaxHeight') specifies the variable named 'MaxHeight'.

  • A numeric scalar indicating the table variable index. For example, geobubble(__,'SizeVariable',16) specifies the sixteenth variable in the table.

  • A logical vector containing one true element. For example, sizevar = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]) specifies the 16th variable in the table.

This property can only be used when specifying a table as input. The values associated with this table variable must be of a numeric type. When you specify this variable, geobubble stores the data values associated with this variable in the 'SizeData' property and sets the property to read-only.

Output Arguments

collapse all

Geographic bubble chart, returned as a GeographicBubbleChart object.

Introduced in R2017b

Was this topic helpful?