Line specification
Plotting functions accept line specifications as arguments and modify the graph generated accordingly. You can specify these three components:
Line style
Marker symbol
Color
For example:
plot(x,y,'-.or')
plots y
versus x
using
a dash-dot line (-.
), places circular
markers (o
) at the data points, and colors both
line and marker red (r
). Specify the components
(in any order) as a character vector after the data arguments. Note
that linespecs are not name-value pairs.
If you specify a marker, but not a line style, only the markers are plotted. For example:
plot(x,y,'d')
You indicate the line styles, markers, and colors you want to display, detailed in the following tables:
Line Style | Description |
---|---|
- | Solid line |
-- | Dashed line |
: | Dotted line |
-. | Dash-dot line |
Marker | Description |
---|---|
'o' | Circle |
'+' | Plus sign |
'*' | Asterisk |
'.' | Point |
'x' | Cross |
'_' | Horizontal line |
'|' | Vertical line |
's' | Square |
'd' | Diamond |
'^' | Upward-pointing triangle |
'v' | Downward-pointing triangle |
'>' | Right-pointing triangle |
'<' | Left-pointing triangle |
'p' | Pentagram |
'h' | Hexagram |
Color | Description |
---|---|
| yellow |
| magenta |
| cyan |
| red |
| green |
| blue |
| white |
| black |
This page also describes how to specify the properties of lines used for plotting. MATLAB® graphics give you control over these visual characteristics:
LineWidth
— Specifies
the width (in points) of the line.
MarkerEdgeColor
— Specifies
the color of the marker or the edge color for filled markers (circle,
square, diamond, pentagram, hexagram, and the four triangles).
MarkerFaceColor
— Specifies
the color of the face of filled markers.
MarkerSize
— Specifies
the size of the marker in points (must be greater than 0).
In addition, you can specify the LineStyle
, Color
,
and Marker
properties instead of using a line specification
character vector. This is useful if you want to specify a color that is not in the list
by using RGB triplet values. See Line Properties for details on these properties.