Choosing line type and color in Gnuplot 4.0

Viewed 228988

I have two pairs of datasets, which I need to plot using Gnuplot.

I want the first pair to be plotted in red, one solid and one dashed. The second pair, I want to plot in blue, one solid and one dashed.

I've experimented with set style line several times, but I cannot get this exact behaviour. My last attempt (attached) plots the first pair in red (solid) and the second pair in blue (dotted).

Any help will be greatly appreciated.

set style line 1 lt 1 lw 3 pt 3
set style line 2 lt 1 lw 3 pt 3
set style line 3 lt 3 lw 3 pt 3
set style line 4 lt 3 lw 3 pt 3
plot 'data1.dat' using 1:3 w l ls 1,\
     'data1.dat' using 1:4 w l ls 2,\
     'data2.dat' using 1:3 w l ls 3,\
     'data2.dat' using 1:4 w l ls 4
7 Answers

You need to use linecolor instead of lc, like:

set style line 1 lt 1 lw 3 pt 3 linecolor rgb "red"

"help set style line" gives you more info.

Edit: Sorry, this won't work for you. I just remembered the line color thing is in 4.2. I ran into this problem in the past and my fix was to upgrade gnuplot.

You can control the color with set style line as well. "lt 3" will give you a dashed line while "lt 1" will give you a solid line. To add color, you can use "lc rgb 'color'". This should do what you need:


set style line 1 lt 1 lw 3 pt 3 lc rgb "red"
set style line 2 lt 3 lw 3 pt 3 lc rgb "red"
set style line 3 lt 1 lw 3 pt 3 lc rgb "blue"
set style line 4 lt 3 lw 3 pt 3 lc rgb "blue"

Related