1
votes

I use gnuplot for plotting data from 4 files on a single graph (png).

I get the 4 plots as different colored lines.

I want them to be of different line types so that the plot can be easily recognized in a black and white print out.

How to do that ? Many thanks for your help.

So what I want is http://gnuplot.sourceforge.net/demo/lines_arrows.html : Second figure. In Gnuplot, I get the plots as different colored lines.

1
what version of gnuplot do you use? Try to check if the terminal (pngcairo) supports dash lines by typing set termoption dashed; test in gnuplot (you should see a window with different objects, some of them will or not be dashed lines). Since version 5.0 you can use the option dashtype or dt to change the dash style, e.g. plot 'data1' dt 1, 'data2' dt 2 (type help dashtype in gnuplot 5.0 for more info). - vagoberto

1 Answers

0
votes

Not entirely sure which detail of your question is the aspect you're struggeling with. When plotting from multiple files you specify this with plot 'FILENAME' using COLUMNS ... , 'FILENAME2' using COLUMNS ...

From the example you posted I see that the lines are black as long as lt -1 stays in. If you take it out, things become colorful. linespoints essentially connects the dots with lines, in the example that's pulled up to set style func linespoints which won't work here, as it's not a function which gets plotted.

Following the example you linked I suggest this:

set title ""
set xlabel ""
set bmargin 6
set offset .05, .05
set xrange [-0.5:3.3]

plot 'd1' using 1:2 lt -1  pt 6 ps 2 title 'pt 6' with linespoints,\
     'd2' using 1:2 lt -1  pt 5 ps 2 title 'pt 5' with linespoints,\
     'd3' using 1:2 lt -1  pt 7 ps 2 title 'pt 7' with linespoints,\
     'd4' using 1:2 lt -1  pt 4 ps 2 title 'pt 4' with linespoints

where d1 looks like:

-0.5  0.8775825619
-0.4  0.921060994
-0.3  0.9553364891
-0.2  0.9800665778
-0.1  0.9950041653
 0.0  1.0000000000
 0.1  0.9950041653
 0.2  0.9800665778
 0.3  0.9553364891
 0.4  0.921060994
 0.5  0.8775825619
 0.6  0.8253356149
 0.7  0.7648421873
 0.8  0.6967067093
 0.9  0.6216099683
 1.0  0.5403023059
 1.1  0.4535961214
 1.2  0.3623577545
 1.3  0.2674988286
 1.4  0.1699671429
 1.5  0.0707372017
 1.6 -0.0291995223
 1.7 -0.1288444943
 1.8 -0.2272020947
 1.9 -0.3232895669
 2.0 -0.4161468365
 2.1 -0.5048461046
 2.2 -0.5885011173
 2.3 -0.6662760213
 2.4 -0.7373937155
 2.5 -0.8011436155
 2.6 -0.8568887534
 2.7 -0.904072142
 2.8 -0.9422223407
 2.9 -0.9709581651
 3.0 -0.9899924966
 3.1 -0.9991351503
 3.2 -0.9982947758
 3.3 -0.9874797699

EDIT:

thanks for clarifying. A few more pointers

Colors themselves: I recommend http://colorbrewer2.org/ to pick colors which are "photocopy safe". These tend to be well distinguishable even if printed in grayscale.

Markers: with the point type e.g. pt 5 you can specify different markers for the data. I changed the size with ps 2 in the above example. Especially open and filled markers are easily distinguishable from each other.

Linestyle: you need version 5 of gnuplot:

New features in version 5 * The dot-dash pattern of a line can now be specified independent of other line properties. See dashtype (p. 37), set dashtype (p. 115), set linetype (p. 135).

Without upgrading I couldn't get this to run, which is derived from the page you linked:

set termoption dash
unset colorbox
set title ""
set xlabel ""
set bmargin 6
set offset .05, .05
set xrange [-0.5:3.3]
show style line

plot 'd2' using 1:2 with linespoints dt 2 lw 3 lc rgb "black" ps -1,\
   'd3' using 1:2 with linespoints dt 1      lc rgb "black" ps -1,\
   'd4' using 1:2 with linespoints dt 3      lc rgb "black" ps -1

here dt is short for dash type, lw is line width, lc is line color which i set to black, ps is point style, disabled, so we don't see the points but only lines