2
votes

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.

1
The command test is a nice way to see exactly how your current terminal is behaving. - mgilson

1 Answers

2
votes

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