2

How to plot a dashed grey line using gnuplot? set style line 1 lt 2 lc rgb "grey" lw 1

I tried:

plot "-" using 1:2, \
     "-" using 1:2, \
     "-" using 1:2 ls 1,\
     "-" using 1:2 ls 1
1.5 17
1.7 16
e
1.5 10
1.7 8
e
1.5 0
1.5 20
e
7 0
7 20
e

There should be two vertical dashed grey lines, but there are actually only the points.

Thor
  • 45,082
  • 11
  • 119
  • 130
Razer
  • 7,843
  • 16
  • 55
  • 103

1 Answers1

2

To have the plot command default to with lines, you need set style data lines. You have to specify termoption dashed to get dashed lines, but that also means that linetype 2 and up are dashed or dotted. I think defining the appropriate line styles is the best approach:

set termoption dashed

set style data lines
set style line 1 lt 2 lc rgb "grey" lw 1
set style line 2 lt 1 lc 1 lw 1
set style line 3 lt 1 lc 2 lw 1

plot "-" using 1:2 ls 2, \
     "-" using 1:2 ls 3, \
     "-" using 1:2 ls 1, \
     "-" using 1:2 ls 1
1.5 17
1.7 16
e
1.5 10
1.7 8
e
1.5 0
1.5 20
e
7 0
7 20
e
Thor
  • 45,082
  • 11
  • 119
  • 130
  • 1
    Another issue was, that dashed lines don't work with the `png` backend. I had to change to `set terminal pngcairo` – Razer Mar 12 '13 at 09:59