Plot in Geographic Coordinates

If you have data that is associated with specific geographic locations, use a geographic axes or chart to visualize your data on a map and provide visual context. For example, if you have data that describes the occurrences of tsunamis around the world, plot the data in a geographic axes where a marker indicates the location of each occurrence on a map. These examples show how to create line plots, scatter plots, bubble charts, and density plots in geographic coordinates.

Create Geographic Line Plot

Draw a line on a map between Seattle and Anchorage. Specify the latitude and longitude for each city. Plot the data on a map using the geoplot function. The example also specifies the color of the line.

latSeattle = 47 + 37/60;
lonSeattle = -(122 + 20/60);
latAnchorage = 61 + 12/60;
lonAnchorage = -(149 + 54/60);

geoplot([latSeattle latAnchorage],[lonSeattle lonAnchorage],'g-*')

Create Geographic Scatter Plot

Create latitude and longitude positions and define values at each point. Plot the values on a map using the geoscatter function. The example specifies the triangle as the marker, with size and color representing variations in the values.

lon = (-170:10:170);
lat = 50 * cosd(3*lon);
A = 101 + 100*(sind(2*lon));
C = cosd(4*lon);

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

Create Geographic Bubble Chart

Read tsunami data into the workspace from a table. Define one value as a categorical value. Plot the data on a map using the geobubble function. The example uses the size of the bubble to indicate the height of the tsunami wave and color to indicate the cause of the tsunami.

tsunamis = readtable('tsunamis.xlsx');
tsunamis.Cause = categorical(tsunamis.Cause);
figure


gb = geobubble(tsunamis,'Latitude','Longitude', ...
        'SizeVariable','MaxHeight','ColorVariable','Cause');
geolimits([10 65],[-180 -80])
title 'Tsunamis in North America';
gb.SizeLegendTitle = 'Maximum Height';

Create Geographic Density Plot

Read tsunami data into the workspace from a table. Plot the data using the geodensityplot function.

tsunamis = readtable('tsunamis.xlsx');
lat = tsunamis.Latitude;
lon = tsunamis.Longitude;
weights = tsunamis.MaxHeight;

geodensityplot(lat,lon,weights)
geolimits([10 65],[-180 -80])

See Also

| | | | |

Related Topics