Written and maintained by CASRAI Editorial Board
Last updated
The short answer: in MATLAB, the LineStyle property of a line takes one of five values: "-" (solid, the default), "--" (dashed), ":" (dotted), "-." (dash-dotted) or "none" (no line). You set it either with a line specification such as plot(x,y,'--') or by assigning p.LineStyle = '--' on the line object that plot returns. This page is for researchers and analysts who need figures that stay readable in black and white, and it also covers how MATLAB cycles styles across several lines (also searched as “linestyle matlab”). It was checked against the MathWorks documentation on 2026-11-07.
What LineStyle is used for in research figures
Colour alone often fails in print, on photocopies and for readers with colour-vision differences. Varying the line style lets several series in one axes stay distinguishable. The MathWorks documentation describes line style, width, marker and colour as properties of the line object that plot creates. For colour choices see MATLAB plot color; for the wider plotting workflow see MATLAB graph plot: labels, subplots and export.
Install or access
LineStyle is part of core MATLAB graphics; no toolbox is named on the property documentation pages. MATLAB is obtained from MathWorks (mathworks.com), usually through a campus or institutional licence. For background on what the software is used for, see what MATLAB is used for.
Step by step: setting the line style
Option 1: a line specification in the plot call
- Call
plotwith a style string as the last argument. For example,plot(x,y,'--')draws a dashed line. - Add marker and colour characters in the same string. The MathWorks example
plot(x,y,'--or')draws a dashed red line with circle markers. - To draw a marker-only series, use a marker without a line character, or set the line style to
"none"(see Option 2).
Option 2: the LineStyle property
- Keep the object that
plotreturns:p = plot(x,y); - Assign the property:
p.LineStyle = '--'; - Optionally set the width:
p.LineWidth = 3;. The same can be passed as name-value arguments, for exampleplot(x,y,'-o','LineWidth',3).
Values of LineStyle
| Value | Result | Note |
|---|---|---|
"-" |
Solid line | Default |
"--" |
Dashed line | |
":" |
Dotted line | |
"-." |
Dash-dotted line | |
"none" |
No line | Markers, if any, are still drawn |
Source: MathWorks, “Line Properties” and “Specify Line and Marker Appearance in Plots,” read 2026-11-07. LineWidth defaults to 0.5 points (1 point is 1/72 inch), cannot render thinner than one pixel, and with markers it also affects the marker edges.
Cycling styles across several lines: LineStyleOrder
Instead of styling each line in a loop, you can set the axes property LineStyleOrder. Its default is "-" only. It accepts a character vector, cell array or string array, and an element can combine a line style with a marker, such as "-*". Setting it updates existing lines, and later plots in the same axes keep using it.
By default MATLAB moves to the next style only after cycling through all the colours in ColorOrder. The axes property LineStyleCyclingMethod (introduced in R2023a) changes that and takes "aftercolor" (default), "beforecolor" or "withcolor". Choosing "beforecolor" or "withcolor" changes when the style advances relative to the colour, so you do not have to wait for the colour list to be exhausted before a second style appears. LineStyleOrderIndex defaults to 1; the documentation recommends setting SeriesIndex on individual plot objects rather than editing the order indices by hand.
Output and how to read it
Check the figure at its final printed size after changing LineWidth, since width also affects marker edges. A series with LineStyle set to "none" shows only its markers, which is the usual way to display raw observations beside a fitted line.
Troubleshooting
My style stopped changing automatically
Setting LineStyle by hand sets LineStyleMode to "manual", which stops automatic style selection for that line. Remove the manual setting or let LineStyleOrder control the styles.
I want a custom dash pattern
The documented LineStyle values are the five above; the property page lists no way to define custom dash lengths. Matplotlib, listed below, documents dash tuples for that purpose.
Free alternatives
| Tool | Line style options (from its own documentation) |
|---|---|
| Matplotlib (Python) | Strings “solid”, “dotted”, “dashed”, “dashdot”; a dash tuple gives finer control over the on/off sequence |
| GNU Octave | Line styles solid (default), dashed, dotted, dash-dot and “none” |
Sources: Matplotlib 3.11.2 “Linestyles” gallery page and GNU Octave manual “Line Styles,” both read 2026-11-07. For a comparison of MATLAB with another free option see MATLAB vs R.
FAQ
What are the line styles in MATLAB?
Solid "-", dashed "--", dotted ":", dash-dotted "-.", and "none". Solid is the default.
How do I change the line style of an existing plot?
Get the line object, either from p = plot(...) or from the axes children, and assign p.LineStyle = ':'.
How do I use different line styles for several lines without a loop?
Set the axes LineStyleOrder (for example to a string array of styles) and choose a LineStyleCyclingMethod (R2023a or later).
Sources
- MathWorks, Specify Line and Marker Appearance in Plots, read 2026-11-07.
- MathWorks, Line Properties, read 2026-11-07.
- MathWorks, Axes Properties, read 2026-11-07.
- Matplotlib, Linestyles, read 2026-11-07.
- GNU Octave, Line Styles, read 2026-11-07.







