MATLAB geoplot in MATLAB®

Learn how to make 5 geoplot charts in MATLAB, then publish them to the Web with Plotly.


Create Geographic Plot

Plot a straight line between two points on a map. Specify the endpoints of the line using the coordinates of Seattle and Anchorage. Specify latitude and longitude in degrees.

latSeattle = 47.62; lonSeattle = -122.33; latAnchorage = 61.20; lonAnchorage = -149.9;

Plot the data on a map. Customize the appearance of the line using the line specification 'g-*'. Adjust the latitude and longitude limits of the map using geolimits.

geoplot([latSeattle latAnchorage],[lonSeattle lonAnchorage],'g-*')
geolimits([45 62],[-149 -123])

fig2plotly()

Add Text to Geographic Plot

Plot a straight line between two points on a map. Specify the endpoints of the line using the coordinates of Seattle and Anchorage. Specify latitude and longitude in degrees.

latSeattle = 47.62; lonSeattle = -122.33; latAnchorage = 61.20; lonAnchorage = -149.9;

Plot the data using geoplot. Customize the appearance of the line using the line specification 'g-*'. Adjust the latitude and longitude limits of the map using geolimits.

geoplot([latSeattle latAnchorage],[lonSeattle lonAnchorage],'g-*')
geolimits([45 62],[-149 -123])

fig2plotly()

Identify Anchorage using the text function.

text(latAnchorage,lonAnchorage,'Anchorage');

Identify Seattle using the text function. Adjust the alignment of the text label by specifying properties of the Text object.

text(latSeattle,lonSeattle,'Seattle',... 'HorizontalAlignment','right',... 'VerticalAlignment','bottom');

Customize Individual Lines on Map

Specify the latitude and longitude coordinates of Seattle, Anchorage, and Point Barrow.

latSeattle = 47.62; lonSeattle = -122.33;

latAnchorage = 61.20; lonAnchorage = -149.9;

latPtBarrow = 71.38; lonPtBarrow = -156.47;

Plot straight lines from Seattle to each of the other two cities. Draw a solid yellow line from Seattle to Anchorage and a dotted blue line between Seattle and Point Barrow. Adjust the latitude and longitude limits of the map using geolimits.

geoplot([latSeattle latAnchorage],[lonSeattle lonAnchorage],'y-',...
    [latSeattle latPtBarrow],[lonSeattle lonPtBarrow],'b:')
geolimits([44 73],[-149 -123])

fig2plotly()

Label each city on the map using the text function.

text(latAnchorage,lonAnchorage,'Anchorage'); text(latPtBarrow,lonPtBarrow,'Point Barrow'); text(latSeattle,lonSeattle,'Seattle',... 'VerticalAlignment','bottom');

Use Chart Line Properties to Customize Appearance of the Line

Plot a straight line between two points on a map. Specify the endpoints of the line using the coordinates of Seattle and Anchorage. Specify latitude and longitude in degrees.

latSeattle = 47.62; lonSeattle = -122.33; latAnchorage = 61.20; lonAnchorage = -149.9;

Plot the data using geoplot. Adjust the latitude and longitude limits of the map using geolimits. Customize the appearance of the line by specifying the LineWidth and Color properties.

geoplot([latSeattle latAnchorage],[lonSeattle lonAnchorage],...
    'LineWidth',2,'Color',[.6 0 0])
geolimits([45 62],[-149 -123])

fig2plotly()

Change Basemap Used in Geographic Plot

Plot a straight line between two points on a map. Specify the endpoints of the line using the coordinates of Seattle and Anchorage. Specify latitude and longitude in degrees.

latSeattle = 47.62; lonSeattle = -122.33; latAnchorage = 61.20; lonAnchorage = -149.9;

Plot the data using geoplot. Adjust the latitude and longitude limits of the map using geolimits.

geoplot([latSeattle latAnchorage],[lonSeattle lonAnchorage])
geolimits([45 62],[-149 -123])

fig2plotly()

Change the basemap used in the plot using the geobasemap function.

geobasemap colorterrain