Main Content

Display Vector Data as Points and Lines

This example shows how to display vector data on an axesm-based map using points and lines. axesm-based maps enable you to display geographic data using a map projection.

Load a MAT-file containing the coordinates of global coastlines into the workspace. The variables within the MAT-file, coastlat and coastlon, specify numeric latitude and longitude coordinates.

load coastlines

Set up a map using the Mollweide projection. Customize the color and line width of the frame.

axesm mollweid

Display the coastline data by using the plotm function. Customize the thickness and color of the line.


Specify the locations of three cities (Cairo, Rio de Janeiro, and Perth). Plot red star markers at those locations.

citylat = [30 -23 -32]; 
citylon = [32 -43 116];

Figure contains an axes object. The axes object contains 3 objects of type patch, line.

Find the coordinates of two tracks and display them on the map.

  • Display a great circle track from Cairo to Rio de Janeiro using a dashed magenta line.

  • Display a rhumb line track from Cairo to Perth using a solid black line.

[gclat,gclon] = track2("gc",citylat(1),citylon(1),citylat(2),citylon(2));

[rhlat,rhlon] = track2("rh",citylat(1),citylon(1),citylat(3),citylon(3));

Figure contains an axes object. The axes object contains 5 objects of type patch, line.

Alternatively, you can plot geographic data over axesm-based maps by using the geoshow function.


  • To plot data that is already in projected coordinates, use a regular axes object and the mapshow function.

  • You can create a similar plot by using geographic axes and the geoplot function. Geographic axes enable you to specify basemaps, change the geographic limits, and interactively pan and zoom. The geoplot function displays data into a Web Mercator map projection.

hold on
geobasemap topographic
geolimits([-72 85],[-180 180])

Figure contains an axes object. The axes object contains 4 objects of type line.

See Also



Related Topics