Every gnuplot curve is styled by four properties: its color (linecolor), width (linewidth), dash pattern (dashtype) and, for markers, its symbol (pointtype). You can set them per plot or save them as reusable line styles, as this script shows.
set style line 1 linecolor rgb "#e41a1c" linewidth 2 pointtype 7 pointsize 1.2
set style line 2 linecolor rgb "#377eb8" linewidth 2 dashtype 2 pointtype 5 pointsize 1.2
set title "Two Series, Two Styles"
set xlabel "x"
set ylabel "y"
plot sin(x) with linespoints linestyle 1 title "Solid, filled circles", \
cos(x) with linespoints linestyle 2 title "Dashed, filled squares"
What each part does
set style line N bundles styling into a named, reusable definition. Style 1 is a solid red line (linecolor rgb "#e41a1c") of width 2 with filled-circle markers: pointtype 7 is the filled circle in most terminals, and pointsize 1.2 scales the marker to 120 percent. Style 2 is blue and dashed — dashtype 2 selects the second built-in dash pattern — with filled squares (pointtype 5). In the plot command, linestyle 1 (short form ls 1) applies the whole bundle at once.
Common abbreviations save typing in one-off plots: lc for linecolor, lw for linewidth, pt for pointtype, ps for pointsize and dt for dashtype. So plot sin(x) lc rgb "red" lw 3 dt 2 is a complete, valid one-liner. Colors accept named values (lc rgb "steelblue"), hex values as above, or a linetype number (lc 3).
When you give gnuplot no styling at all, it cycles through linetype 1, 2, 3 and so on for successive plot elements — each linetype pairs a default color with, on some terminals, a dash pattern. That cycle is why multi-curve plots get different colors automatically. Redefining styles up front, as in this script, is the reliable way to keep colors consistent across several figures of a paper or report.
Variants and going further
Custom dash patterns use an array of on/off lengths: dashtype (4,2,1,2) draws 4 units on, 2 off, 1 on, 2 off, repeating. For points-only scatter plots, drop the line entirely with with points and raise pointsize. To preview every point symbol your terminal offers, run test in an interactive session — it draws a test page including the numbered point types.
Common mistakes
- Colors change between figures: you relied on the default linetype cycle but changed the number or order of curves. Define explicit
set style lineentries and reference them by number in every figure. - Dashtype has no visible effect: some terminals render dashes only for lines, and a very short plot range can make a dash pattern look solid. Zoom or extend the range, and check the effect on a file terminal such as pngcairo.
Related tutorials: Titles, Labels and the Key, Axis Ranges, Tics and Log Scales. See also the full Gnuplot Tutorials index.
Try it online: Style experiments are ideal for the online terminal: change one property, re-run, and compare immediately. Paste the script into the Gnuplot Online terminal and run it in your browser — no install needed. To run gnuplot locally instead, see the installation guide and the download page.
Go deeper: For a systematic walk through gnuplot from first plots to publication-ready figures, see Gnuplot in Action by Philipp K. Janert — Janert is a gnuplot developer, and the book is the most complete tutorial reference for the program. Affiliate link: see our Affiliate Disclosure.
