plot3m
Project 3-D lines and points on axesm
-based map
Description
plot3m(
specifies line properties using one or more name-value pair arguments. For example,
lat
,lon
,z
,Name,Value
)"Color","red"
creates a red plot.
returns the line
objects. Use p
= plot3m(___)p
to modify the plot after it is created. For a list of
properties, see Line Properties.
Examples
Display 3-D Line over Terrain Data
Read sample data containing the latitude, longitude, and height coordinates of a UAV. Find the latitude and longitude limits of the data, including a latitude-longitude buffer of 0.02
degrees.
GT = readgeotable("sample_uavtrack.gpx","Layer","track_points"); lat = GT.Shape.Latitude; lon = GT.Shape.Longitude; h = GT.Elevation; [latlim,lonlim] = geoquadline(lat,lon); [latlim,lonlim] = bufgeoquad(latlim,lonlim,0.02,0.02);
Read terrain elevation data, in meters, for the region from the Web Map Service (WMS) server hosted by MathWorks®.
layers = wmsfind("mathworks","SearchField","serverurl"); elevation = refine(layers,"elevation"); [Z,R] = wmsread(elevation,"Latlim",latlim,"Lonlim",lonlim, ... "ImageFormat","image/bil"); Z = double(Z);
Prepare an axesm
-based map of the region. Remove all labels and grid lines.
figure usamap(Z,R) framem off mlabel off plabel off gridm off
Display the terrain elevation data as a surface. Specify a colormap appropriate for elevation data.
geoshow(Z,R,"DisplayType","surface") demcmap(Z)
Plot the terrain elevation data over the surface.
plot3m(lat,lon,h,"k")
View the map in 3-D. Vertically exaggerate the terrain by a factor of 5
.
view([-130 15])
daspectm("meters",5)
Project 3-D Lines on axesm
-Based Map
Read two data sets into the workspace:
A grid of world geoid heights from the Earth Gravitational Model of 1996. The variable
N
specifies geoid heights in meters, and the variableR
is the spatial reference forN
.A MAT file containing global coastline coordinates. The variables within the MAT file,
coastlat
andcoastlon
, specify latitude and longitude coordinates, respectively.
[N,R] = egm96geoid;
load coastlines
Create a world map.
figure worldmap world plabel off mlabel off
Display the geoid heights as a 3-D surface. Then, display the coastline coordinates as a 2-D black line.
geoshow(N,R,"DisplayType","surface") plotm(coastlat,coastlon,"k")
In some places, the coastlines are obscured by the surface. Display the coastline coordinates again, this time using a 3-D line. Specify the height of the line using a value that is 1
meter more than the maximum geoid height.
h = max(max(N)) + 1;
plot3m(coastlat,coastlon,h,"k")
Input Arguments
lat
— Latitude coordinates
scalar | vector | matrix
Latitude coordinates, specified as a scalar, vector, or matrix. The sizes of
lat
and lon
must match. Specify
lat
in the units indicated by the AngleUnits
property of the axesm
-based map.
The size and shape of lat
depends on the type of plot you want
to create.
Type of Plot | How to Specify Coordinates |
---|---|
Single point | Specify plot3m(1,2,3,"o") |
One set of points | Specify plot3m([1 2 3],[4 5 6],[7 8 9]) |
Multiple sets of points (using vectors) | Specify plot3m([1 2 3 NaN 1 2 3],[4 5 6 NaN 7 8 9],[10 11 12 NaN 13 14 15]) |
Multiple sets of points (using matrices) | Specify plot3m([1 2 3; 1 2 3],[4 5 6; 7 8 9],[10 11 12; 13 14 15]) |
Data Types: double
lon
— Longitude coordinates
scalar | vector | matrix
Longitude coordinates, specified as a scalar, vector, or matrix. The sizes of
lon
and lat
must match. Specify
lon
in the units indicated by the AngleUnits
property of the axesm
-based map.
The size and shape of lon
depends on the type of plot you want
to create.
Type of Plot | How to Specify Coordinates |
---|---|
Single point | Specify plot3m(1,2,3,"o") |
One set of points | Specify plot3m([1 2 3],[4 5 6],[7 8 9]) |
Multiple sets of points (using vectors) | Specify plot3m([1 2 3 NaN 1 2 3],[4 5 6 NaN 7 8 9],[10 11 12 NaN 13 14 15]) |
Multiple sets of points (using matrices) | Specify plot3m([1 2 3; 1 2 3],[4 5 6; 7 8 9],[10 11 12; 13 14 15]) |
Data Types: double
z
— Heights
scalar | vector of same size as lat
and lon
| matrix of same size as lat
and lon
Heights, specified as a scalar, a vector of the same size as
lat
and lon
, or a matrix of the same size as
lat
and lon
.
In most cases, the units of z
are arbitrary. When the
MapProjection
property of the axesm
-based
map is "globe"
, z
is referenced to the
ellipsoid. In this case, specify z
using the length unit of the
ellipsoid.
Data Types: double
LineSpec
— Line style, marker, and color
string scalar | character vector
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 Style | Description | Resulting Line |
---|---|---|
"-" | Solid line |
|
"--" | Dashed line |
|
":" | Dotted line |
|
"-." | Dash-dotted line |
|
Marker | Description | Resulting Marker |
---|---|---|
"o" | Circle |
|
"+" | Plus sign |
|
"*" | Asterisk |
|
"." | Point |
|
"x" | Cross |
|
"_" | Horizontal line |
|
"|" | Vertical line |
|
"square" | Square |
|
"diamond" | Diamond |
|
"^" | Upward-pointing triangle |
|
"v" | Downward-pointing triangle |
|
">" | Right-pointing triangle |
|
"<" | Left-pointing triangle |
|
"pentagram" | Pentagram |
|
"hexagram" | Hexagram |
|
Color Name | Short Name | RGB Triplet | Appearance |
---|---|---|---|
"red" | "r" | [1 0 0] |
|
"green" | "g" | [0 1 0] |
|
"blue" | "b" | [0 0 1] |
|
"cyan"
| "c" | [0 1 1] |
|
"magenta" | "m" | [1 0 1] |
|
"yellow" | "y" | [1 1 0] |
|
"black" | "k" | [0 0 0] |
|
"white" | "w" | [1 1 1] |
|
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: plot3m(lat,lon,z,LineStyle="--")
displays dashed
lines.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: plot3m(lat,lon,z,"LineStyle","--")
displays dashed
lines.
Note
Use name-value arguments to specify values for the properties of the
Line
object created by this function. The properties listed here are
only a subset. For a full list, see Line Properties.
Setting the XData
, YData
, and
ZData
properties of the line object is not supported.
Color
— Color
[0 0.4470 0.7410]
(default) | RGB triplet | hexadecimal color code | 'r'
| 'g'
| 'b'
| ...
Color, specified as an RGB triplet, a hexadecimal color code, a color name, or a
short name. The color you specify sets the line color. It also sets the marker edge
color when the MarkerEdgeColor
property is set to
'auto'
.
For a custom color, specify an RGB triplet or a hexadecimal color code.
An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range
[0,1]
, for example,[0.4 0.6 0.7]
.A hexadecimal color code is a string scalar or character vector that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. The values are not case sensitive. Therefore, the color codes"#FF8800"
,"#ff8800"
,"#F80"
, and"#f80"
are equivalent.
Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"red" | "r" | [1 0 0] | "#FF0000" | |
"green" | "g" | [0 1 0] | "#00FF00" | |
"blue" | "b" | [0 0 1] | "#0000FF" | |
"cyan"
| "c" | [0 1 1] | "#00FFFF" | |
"magenta" | "m" | [1 0 1] | "#FF00FF" | |
"yellow" | "y" | [1 1 0] | "#FFFF00" | |
"black" | "k" | [0 0 0] | "#000000" | |
"white" | "w" | [1 1 1] | "#FFFFFF" | |
"none" | Not applicable | Not applicable | Not applicable | No color |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[0 0.4470 0.7410] | "#0072BD" | |
[0.8500 0.3250 0.0980] | "#D95319" | |
[0.9290 0.6940 0.1250] | "#EDB120" | |
[0.4940 0.1840 0.5560] | "#7E2F8E" | |
[0.4660 0.6740 0.1880] | "#77AC30" | |
[0.3010 0.7450 0.9330] | "#4DBEEE" | |
[0.6350 0.0780 0.1840] | "#A2142F" |
LineWidth
— Line width
0.5
(default) | positive value
Line width, specified as a positive value in points, where 1 point = 1/72 of an inch. If the line has markers, then the line width also affects the marker edges.
The line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.
MarkerSize
— Marker size
6
(default) | positive value
Marker size, specified as a positive value in points, where 1 point = 1/72 of an inch.
MarkerEdgeColor
— Marker outline color
"auto"
(default) | RGB triplet | hexadecimal color code | "r"
| "g"
| "b"
| ...
Marker outline color, specified as "auto"
, an RGB triplet, a
hexadecimal color code, a color name, or a short name. The default value of
"auto"
uses the same color as the Color
property.
For a custom color, specify an RGB triplet or a hexadecimal color code.
An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range
[0,1]
, for example,[0.4 0.6 0.7]
.A hexadecimal color code is a string scalar or character vector that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. The values are not case sensitive. Therefore, the color codes"#FF8800"
,"#ff8800"
,"#F80"
, and"#f80"
are equivalent.
Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"red" | "r" | [1 0 0] | "#FF0000" | |
"green" | "g" | [0 1 0] | "#00FF00" | |
"blue" | "b" | [0 0 1] | "#0000FF" | |
"cyan"
| "c" | [0 1 1] | "#00FFFF" | |
"magenta" | "m" | [1 0 1] | "#FF00FF" | |
"yellow" | "y" | [1 1 0] | "#FFFF00" | |
"black" | "k" | [0 0 0] | "#000000" | |
"white" | "w" | [1 1 1] | "#FFFFFF" | |
"none" | Not applicable | Not applicable | Not applicable | No color |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[0 0.4470 0.7410] | "#0072BD" | |
[0.8500 0.3250 0.0980] | "#D95319" | |
[0.9290 0.6940 0.1250] | "#EDB120" | |
[0.4940 0.1840 0.5560] | "#7E2F8E" | |
[0.4660 0.6740 0.1880] | "#77AC30" | |
[0.3010 0.7450 0.9330] | "#4DBEEE" | |
[0.6350 0.0780 0.1840] | "#A2142F" |
MarkerFaceColor
— Marker fill color
"none"
(default) | "auto"
| RGB triplet | hexadecimal color code | "r"
| "g"
| "b"
| ...
Marker fill color, specified as "auto"
, an RGB triplet, a
hexadecimal color code, a color name, or a short name. The "auto"
option uses the same color as the Color
property of the parent
axes. If you specify "auto"
and the axes plot box is invisible, the
marker fill color is the color of the figure.
For a custom color, specify an RGB triplet or a hexadecimal color code.
An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range
[0,1]
, for example,[0.4 0.6 0.7]
.A hexadecimal color code is a string scalar or character vector that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. The values are not case sensitive. Therefore, the color codes"#FF8800"
,"#ff8800"
,"#F80"
, and"#f80"
are equivalent.
Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"red" | "r" | [1 0 0] | "#FF0000" | |
"green" | "g" | [0 1 0] | "#00FF00" | |
"blue" | "b" | [0 0 1] | "#0000FF" | |
"cyan"
| "c" | [0 1 1] | "#00FFFF" | |
"magenta" | "m" | [1 0 1] | "#FF00FF" | |
"yellow" | "y" | [1 1 0] | "#FFFF00" | |
"black" | "k" | [0 0 0] | "#000000" | |
"white" | "w" | [1 1 1] | "#FFFFFF" | |
"none" | Not applicable | Not applicable | Not applicable | No color |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[0 0.4470 0.7410] | "#0072BD" | |
[0.8500 0.3250 0.0980] | "#D95319" | |
[0.9290 0.6940 0.1250] | "#EDB120" | |
[0.4940 0.1840 0.5560] | "#7E2F8E" | |
[0.4660 0.6740 0.1880] | "#77AC30" | |
[0.3010 0.7450 0.9330] | "#4DBEEE" | |
[0.6350 0.0780 0.1840] | "#A2142F" |
Output Arguments
p
— Line objects
array of Line
objects
Line objects, returned as an array of Line
objects. Use
p
to modify the Line
objects after creation. For
a list of properties, see Line Properties.
Setting the XData
, YData
, and
ZData
properties of the line objects is not supported.
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)