Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choosing line type and color in Gnuplot 4.0

Tags:

gnuplot

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 
like image 859
Escualo Avatar asked Jan 15 '10 22:01

Escualo


2 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.

like image 95
Zitrax Avatar answered Sep 19 '22 18:09

Zitrax


I've ran into this topic, because i was struggling with dashed lines too (gnuplot 4.6 patchlevel 0)

If you use:

set termoption dashed 

Your posted code will work accordingly.

Related question:
However, if I want to export a png with: set terminal png, this isn't working anymore. Anyone got a clue why?

Turns out, out, gnuplots png export library doesnt support this.
Possbile solutions:

  • one can simply export to ps, then convert it with pstopng
  • according to @christoph, if you use pngcairo as your terminal (set terminal pngcairo) it will work
like image 29
p1100i Avatar answered Sep 19 '22 18:09

p1100i