Main Content

geoscatter

Scatter chart in geographic coordinates

Description

example

geoscatter(lat,lon) displays colored circles in a geographic axes at the latitude-longitude locations specified (in degrees) by the vectors lat and lon. lat and lon must be the same size.

geoscatter(lat,lon,A) uses A to specify the area of each marker (in points^2). To draw all the markers with the same size, specify A as a scalar. To draw the markers with different sizes, specify A as a vector the same length as lat and lon. If you do not specify A, geoscatter uses the default size.

geoscatter(lat,lon,A,C) uses C to specify the color of each marker.

geoscatter(___,M) creates a scatter plot where M specifies the marker used. By default, geoscatter uses circles as the marker.

geoscatter(___,'filled') fills the markers.

geoscatter(___,Name,Value) specifies properties of the scatter plot using one or more Name,Value pair arguments. The property settings apply to all the scatter plots.

geoscatter(gx,___) plots into the geographic axes specified by gx instead of into the current axes.

s = geoscatter(___) returns the Scatter object. Use S to modify properties of the object after it is created.

Examples

collapse all

Set up latitude and longitude data.

lon = (-170:10:170);
lat = 50 * cosd(3*lon);

Define data that controls the area of each marker.

A = 101 + 100*(sind(2*lon));

Define data to control the color of each marker.

C = cosd(4*lon);

Plot the data on a geographic scatter plot, specifying the marker size data and the color data. Specify the marker as a triangle, rather than the default circle.

geoscatter(lat,lon,A,C,'^')

Set up latitude and longitude data.

lon = (-170:10:170);
lat = 50 * cosd(3*lon);

Define the data that controls the area of each marker.

A = 101 + 100*(sind(2*lon));

Define the data that controls the color of each marker.

C = cosd(4*lon);

Create the scatter plot on a set of geographic axes, specifying the marker size data and the color data. The example specifies the marker as a triangle, rather than the default circle.

geoscatter(lat,lon,A,C,'^')

Change the basemap of the geographic scatter plot.

geobasemap colorterrain

Input Arguments

collapse all

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

Marker sizes in points squared, specified in one of these forms:

  • Scalar — Uniform marker size. For example, A = 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 lat and lon.

  • 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, geoscatter(lat,lon,[],c).

The SizeData property of the scatter object stores the marker sizes.

Example: 50

Example: [36 25 25 17 46]

Marker color, specified in one of these forms:

  • RGB triplet or color name — Plot all markers with the same color.

  • Three-column matrix of RGB triplets — Use different colors for each marker. Each row of the matrix specifies an RGB triplet color for the corresponding marker. The number of rows must equal the length of lat and lon.

  • Vector — Use different colors for each marker and linearly map values in C to the current colormap. The length of C must equal the length of lat and lon. To change the colormap for the axes, use the colormap function.

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.

Color NameShort NameRGB TripletAppearance
'red''r'[1 0 0]

Sample of the color red

'green''g'[0 1 0]

Sample of the color green

'blue''b'[0 0 1]

Sample of the color blue

'cyan' 'c'[0 1 1]

Sample of the color cyan

'magenta''m'[1 0 1]

Sample of the color magenta

'yellow''y'[1 1 0]

Sample of the color yellow

'black''k'[0 0 0]

Sample of the color black

'white''w'[1 1 1]

Sample of the color white

When you specify marker colors, geoscatter sets the MarkerFaceColor property of the Scatter object to 'flat' and stores the marker colors in the CData property.

Example: 'green'

Example: 'g'

Example: [0 1 0]

Marker symbol, specified as one of these values.

MarkerDescriptionResulting Marker
'o'Circle

Sample of circle marker

'+'Plus sign

Sample of plus sign marker

'*'Asterisk

Sample of asterisk marker

'.'Point

Sample of point marker

'x'Cross

Sample of cross marker

'_'Horizontal line

Sample of horizontal line marker

'|'Vertical line

Sample of vertical line marker

's'Square

Sample of square marker

'd'Diamond

Sample of diamond line marker

'^'Upward-pointing triangle

Sample of upward-pointing triangle marker

'v'Downward-pointing triangle

Sample of downward-pointing triangle marker

'>'Right-pointing triangle

Sample of right-pointing triangle marker

'<'Left-pointing triangle

Sample of left-pointing triangle marker

'p'Pentagram

Sample of pentagram marker

'h'Hexagram

Sample of hexagram marker

Option to fill the interior of the markers, specified as 'filled'. Use this option with markers that have a face, for example, 'o' or 'square'.

Parent geographic axes object, specified as a GeographicAxes object.[1] You can modify the appearance and behavior of a GeographicAxes object by setting its properties. For a list of properties, see GeographicAxes Properties.

Name-Value 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 quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: geoscatter(lat,lon,'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.

Marker symbol, specified as one of these options.

MarkerDescriptionResulting Marker
'o'Circle

Sample of circle marker

'+'Plus sign

Sample of plus sign marker

'*'Asterisk

Sample of asterisk marker

'.'Point

Sample of point marker

'x'Cross

Sample of cross marker

'_'Horizontal line

Sample of horizontal line marker

'|'Vertical line

Sample of vertical line marker

's'Square

Sample of square marker

'd'Diamond

Sample of diamond line marker

'^'Upward-pointing triangle

Sample of upward-pointing triangle marker

'v'Downward-pointing triangle

Sample of downward-pointing triangle marker

'>'Right-pointing triangle

Sample of right-pointing triangle marker

'<'Left-pointing triangle

Sample of left-pointing triangle marker

'p'Pentagram

Sample of pentagram marker

'h'Hexagram

Sample of hexagram marker

'none'No markersNot applicable

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 NameShort NameRGB TripletHexadecimal Color CodeAppearance
'red''r'[1 0 0]'#FF0000'

Sample of the color red

'green''g'[0 1 0]'#00FF00'

Sample of the color green

'blue''b'[0 0 1]'#0000FF'

Sample of the color blue

'cyan' 'c'[0 1 1]'#00FFFF'

Sample of the color cyan

'magenta''m'[1 0 1]'#FF00FF'

Sample of the color magenta

'yellow''y'[1 1 0]'#FFFF00'

Sample of the color yellow

'black''k'[0 0 0]'#000000'

Sample of the color black

'white''w'[1 1 1]'#FFFFFF'

Sample of the color white

'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.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]'#0072BD'

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]'#D95319'

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]'#EDB120'

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]'#7E2F8E'

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]'#77AC30'

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]'#4DBEEE'

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]'#A2142F'

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

Example: [0.5 0.5 0.5]

Example: 'blue'

Example: '#D2F9A7'

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 NameShort NameRGB TripletHexadecimal Color CodeAppearance
'red''r'[1 0 0]'#FF0000'

Sample of the color red

'green''g'[0 1 0]'#00FF00'

Sample of the color green

'blue''b'[0 0 1]'#0000FF'

Sample of the color blue

'cyan' 'c'[0 1 1]'#00FFFF'

Sample of the color cyan

'magenta''m'[1 0 1]'#FF00FF'

Sample of the color magenta

'yellow''y'[1 1 0]'#FFFF00'

Sample of the color yellow

'black''k'[0 0 0]'#000000'

Sample of the color black

'white''w'[1 1 1]'#FFFFFF'

Sample of the color white

'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.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]'#0072BD'

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]'#D95319'

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]'#EDB120'

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]'#7E2F8E'

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]'#77AC30'

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]'#4DBEEE'

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]'#A2142F'

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

Example: [0.3 0.2 0.1]

Example: 'green'

Example: '#D2F9A7'

Width of marker edge, specified as a positive value in point units.

Example: 0.75

Output Arguments

collapse all

Geographic scatter plot, returned as a Scatter object. Use s to access and modify properties of the geographic scatter plot after it has been created.

Tips

  • To customize the geographic axes containing your scatter object, obtain the object's parent, gx = s.Parent, and modify its properties. For a list of properties, see GeographicAxes Properties.

  • If you have Mapping Toolbox™, you can specify basemaps of your own choosing by using the addCustomBasemap function.

  • When you plot on geographic axes, the geoscatter function assumes that coordinates are referenced to the WGS84 coordinate reference system. If you plot using coordinates that are referenced to a different coordinate reference system, then the coordinates may appear misaligned.

Introduced in R2018b

[1] Alignment of boundaries and region labels are a presentation of the feature provided by the data vendors and do not imply endorsement by MathWorks®.