Main Content

plotm

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

Description

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.

example

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.

Examples

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');
plotm(coastlat,coastlon,'g')

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

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];
axesm('UTM','Zone','31N','Frame','on')
plotm(lat,lon)

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
"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

"square"Square

Sample of square marker

"diamond"Diamond

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

"pentagram"Pentagram

Sample of pentagram marker

"hexagram"Hexagram

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.

Tips

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

| |