MATLAB Function Reference Previous page   Next Page
LineSpec

Line specification syntax

Description

This page describes how to specify the properties of lines used for plotting. MATLAB enables you to define many characteristics, including

MATLAB defines string specifiers for line styles, marker types, and colors. The following tables list these specifiers.

Line Style Specifiers

Specifier
Line Style
-
Solid line (default)
--
Dashed line
:
Dotted line
-.
Dash-dot line

Marker Specifiers

Specifier
Marker Type
+
Plus sign
o
Circle
*
Asterisk
.
Point
x
Cross
'square' or s
Square
'diamond' or d
Diamond
^
Upward-pointing triangle
v
Downward-pointing triangle
>
Right-pointing triangle
<
Left-pointing triangle
'pentagram' or p
Five-pointed star (pentagram)
'hexagram' or h
Six-pointed star (hexagram)

Color Specifiers

Specifier
Color
r
Red
g
Green
b
Blue
c
Cyan
m
Magenta
y
Yellow
k
Black
w
White

Many plotting commands accept a LineSpec argument that defines three components used to specify lines:

For example,

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.

Plotting Data Points with No Line

If you specify a marker, but not a line style, MATLAB plots only the markers. For example,

Related Properties

When using the plot and plot3 functions, you can also specify other characteristics of lines using graphics properties:

In addition, you can specify the 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.

Create a plot illustrating how to set line properties.

See Also

line, plot, patch, set, surface, axes LineStyleOrder property

Basic Plots and Graphs for related functions


Previous page  Lineseries Properties linkaxes Next page

© 1994-2005 The MathWorks, Inc.