Main Content

plotm

Project 2-D lines and points on map axes

描述

plotmis the mapping equivalent of the MATLAB®plotfunction.

plotm(lat,lon)displays projected line objects on the current map axes.latandlonare the latitude and longitude coordinates, respectively, of the line object to be projected. This ordering of latitude then longitude is standard geographic usage. However, this ordering is conceptually reversed from the MATLABlinefunction, in which thehorizontal(x) coordinate comes first.

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

example

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 ofLine Propertiesexcept forXData,YData, andZData.Nameis the property name andValueis the corresponding value.Namemust appear inside single quotes (' '). You can specify several name and value pair arguments in any order asName1,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 set of map axes. Then, plot the data. Theplotmfunction uses theNaNvalues incoastlatandcoastlonto break the data into separate lines.

loadcoastlinesax = 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 theAngleUnitsproperty of the map axes.latandlonmust be the same size.

Create breaks in lines or polygons usingNaNvalues. 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 character vector or string 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 Style 描述 Resulting Line
“- - -” Solid line

Sample of solid line

'--' Dashed line

样本的虚线

':' Dotted line

Sample of dotted line

'-.' Dash-dotted line

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

Marker 描述 Resulting 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

's' Square

Sample of square marker

'd' Diamond

Sample of diamond line marker

'^' Upward-pointing triangle

样本upward-pointing三角形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

'p' Pentagram

Sample of pentagram marker

'h' Hexagram

Sample of hexagram marker

Color Name Short Name RGB Triplet Appearance
的d' '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 theplotmfunction, 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 thetrack2function.

Version History

Introduced before R2006a

See Also

||