Main Content


Project 2-D lines and points on axesm-based map


plotm(lat,lon) displays projected line objects on the current axesm-based map. Specify the latitude and longitude coordinates of the line using lat and lon.

To display 2-D line plots on geographic axes or map axes, use the geoplot function instead.

plotm([lat lon]) allows the latitude and longitude coordinates to be packed into a single two-column matrix.


plotm(lat,lon,LineSpec) specifies the line style, marker, and color.

plotm(lat,lon,Name,Value) uses name-value pair arguments to specify any number of Line Properties except for XData, YData, and ZData. Name is the property 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. Property names can be abbreviated, and case does not matter.

h = plotm(___) returns a handle to the displayed line.


collapse all

First, load coastline data into the workspace and create a map. Then, plot the data. The plotm function uses the NaN values in coastlat and coastlon to break the data into separate lines.

load coastlines
ax = axesm('sinusoid','Frame','on');

Input Arguments

collapse all

Latitude or longitude vector, specified as a numeric vector. Specify values in units that match the AngleUnits property of the axesm-based map. lat and lon must be the same size.

Create breaks in lines or polygons using NaN values. For example, this code plots the first three elements, skips the fourth element, and draws another line using the last three elements.

lat = [0 1 2 NaN 4 5 6];
lon = [0 1 2 NaN 3 4 5];

Line style, marker, and color, specified as a string scalar or character vector containing symbols. The symbols can appear in any order. You do not need to specify all three characteristics (line style, marker, and color). For example, if you omit the line style and specify the marker, then the plot shows only the marker and no line.

Example: "--or" is a red dashed line with circle markers.

Line StyleDescriptionResulting Line
"-"Solid line

Sample of solid line

"--"Dashed line

Sample of dashed line

":"Dotted line

Sample of dotted line

"-."Dash-dotted line

Sample of dash-dotted line, with alternating dashes and dots

MarkerDescriptionResulting Marker

Sample of circle marker

"+"Plus sign

Sample of plus sign marker


Sample of asterisk marker


Sample of point marker


Sample of cross marker

"_"Horizontal line

Sample of horizontal line marker

"|"Vertical line

Sample of vertical line marker


Sample of square marker


Sample of diamond 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


Sample of pentagram marker


Sample of hexagram marker

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

Output Arguments

collapse all

Handle to the displayed line, returned as a handle to a MATLAB® graphics object.


When you pass two points to the plotm function, the function projects the locations of each point on the map and displays a straight line that connects them, regardless of the map projection or the distance between the points. To display a projected geodesic or rhumbline curve between two points, first insert intermediate points using the track2 function.

Version History

Introduced before R2006a

See Also

| |