Skip to main content
v2026.11,858 entries · CC-BY 4.0
LAC HealthMedical & Research SuppliesReagents, PPE & instruments — chain-of-custody documented.Fast, traceable sourcing built for regulated research environments, from bench consumables to instrumentation.Shop lac.us CodeCASRAIlac.us

MATLAB LineStyle: Values, Syntax and Cycling

The five MATLAB LineStyle values, two ways to set them, and LineStyleOrder cycling for figures that read in black and white.

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

  1. Call plot with a style string as the last argument. For example, plot(x,y,'--') draws a dashed line.
  2. Add marker and colour characters in the same string. The MathWorks example plot(x,y,'--or') draws a dashed red line with circle markers.
  3. 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

  1. Keep the object that plot returns: p = plot(x,y);
  2. Assign the property: p.LineStyle = '--';
  3. Optionally set the width: p.LineWidth = 3;. The same can be passed as name-value arguments, for example plot(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

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about MATLAB LineStyle: Values, Syntax and Cycling

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →