| MATLAB Function Reference | Search  Help Desk |
| LineSpec | Examples See Also |
Description
This page describes how to specify the properties of lines used for plotting. MATLAB enables you to define many characteristics including:Line Style Specifiers
Specifier
Line Style
- solid line (default)
--dashed line
:dotted line
-. dash-dot line
Marker Specifiers
Color Specifiers
Specifier
Color
rred
ggreen
bblue
ccyan
mmagenta
yyellow
kblack
wwhite
LineSpec argument that defines three components used to specify lines:
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 quoted string after the data arguments.
If you specify a marker, but not a line style, MATLAB plots only the markers. For example,
plot(x,y,'d')
Related Properties
When using theplot and plot3 functions, you can also specify other characteristics of lines using graphics properties:
LineWidth - specifies the width (in points) of the line
MarkerEdgeColor - specifies the color of the marker or the edge color forfilled 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.
LineStyle, Color, and Marker properties instead of using the symbol string. This is useful if you want to specify a color that is not in the list by using RGB values. See ColorSpec for more information on color.
Examples
Plot the sine function over three different ranges using different line styles, colors, and markers.t = 0:pi/20:2*pi; plot(t,sin(t),'-.r*') hold on plot(sin(t-pi/2),'--mo') plot(sin(t-pi),':bs') hold offCreate a plot illustrating how to set line properties.
plot(t,sin(2*t),'-mo',... 'LineWidth',2,... 'MarkerEdgeColor','k',... 'MarkerFaceColor',[.49 1 .63],... 'MarkerSize',12)
See Also
line, plot, patch, set, surface, axesLineStyleOrder property