| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
To modify the style, width, and color of lines on a graph, use
the Property Editor, one of the plotting tools
. For details, see The
Property Editor in the MATLAB Graphics documentation.
This page describes how to specify the properties of lines used for plotting. MATLAB graphics give you control over these visual characteristics:
Line style
Line width
Color
Marker type
Marker size
Marker face and edge coloring (for filled markers)
You indicate the line styles, marker types, and colors you want to display using string specifiers, detailed in the following tables:
| Specifier | Line Style |
|---|---|
| - | Solid line (default) |
| -- | Dashed line |
| : | Dotted line |
| -. | Dash-dot line |
Specifier | Marker Type |
|---|---|
| + | Plus sign |
| o | Circle |
| * | Asterisk |
| . | Point (see note below) |
| 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) |
Specifier | Color |
|---|---|
| r | Red |
| g | Green |
| b | Blue |
| c | Cyan |
| m | Magenta |
| y | Yellow |
| k | Black |
| w | White |
All high-level plotting functions (except for the ez... family of function-plotting functions) accept a LineSpec argument that defines three components used to specify lines:
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 quoted string after the data arguments. Note that linespecs are single strings, not property-value pairs.
If you specify a marker, but not a line style, only the markers are plotted. For example:
plot(x,y,'d')
When using the plot 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 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 the symbol string. This is useful if you want to specify a color that is not in the list by using RGB values. See Line Properties for details on these properties and ColorSpec for more information on color.
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(t,sin(t-pi/2),'--mo') plot(t,sin(t-pi),':bs') hold off

Create a plot illustrating how to set line properties:
plot(t,sin(2*t),'-mo',...
'LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor',[.49 1 .63],...
'MarkerSize',12)

axes, line, plot, patch, set, surface, Line Properties, ColorSpec
Line Styles Used for Plotting — LineStyleOrder for information about defining an order for applying linestyles
Types of MATLAB Plots for functions that use linespecs
Basic Plots and Graphs for related functions
![]() | Lineseries Properties | linkaxes | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |