GNUplot

  • Website, downloads for Windows and Unix based systems: gnuplot.info
  • Ubuntu:
    #sudo apt-get install gnuplot

Plot Option Every

  • This is used to define which part of the datafile you want to plot. It also allows to you to jump over a number of lines.
  • The syntax for every is:
  • every I:J:K:L:M:N

    where:
    I Line increment
    J Data block increment
    K The first line
    L The first data block
    M The last line
    N The last data block

    Examples:
    every 2 plot every 2 line
    every ::3 skip the first 3 lines
    every ::3::5 plot from the 4-th to 6-th lines
    every ::0::0 plot the first line only (first line = 0)
    every 2::::6 plot the 1,3,5,7-th lines
    every :2 plot every 2 data block
    every :::5::8 plot from 5-th to 8-th data blocks
    Data blocks are separated by blank lines in the file
    plot 'dataset.dat' u 1:4 every ::2::283 pt 2 t 'plot lines 3-284'

Postscript Output, Enhanced

  • set terminal postscript eps color blacktext dashed enhance dl 4.0 lw 2.0 18
  • replace dashed for solid to have solid colored lines
  • replace color by monochrome for black-white output
  • the last number (here 18) is the fontsize
  • If you want the legend to be printed in a small font, and the axis description and tics larger, do like this: 1) Set the font in the 'set terminal' to 11. 2) set the linewidth and borders a bit different ' dl 3.0 lw 3.0'. 3) and next:
    set xtics out auto font 'Helvetica,16' nomirror
    set ytics out auto font 'Helvetica,16' nomirror
    
    and in the label, key and plot commands:
    set xlabel '{/Helvetica=16 x (mm)}'
    set ylabel '{/Helvetica=16 S_{total} (g/kg)}'
    set key title '{/Helvetica=16 C_0: 0.08 g/l}'
    plot  '.data.dat' using 1:2 title 'small font title'
    
  • enhanced enables the posibility for sub- and super script and all kinds of special characters. More detail in the Gnuplot Enhanced Postscript Output (EN, 6.5 kB PDF) Two page overview of the syntax used for scientific text in EPS plots

Multiplot

  • To create a nice page with four plots on top of each other that are readable when printed inside one column of a two-column paper layout (including different fonts as an example):
  • set size 1.0,2.0
    set border 15 lw 0.3 
    
    set rmargin 0 
    set lmargin 0 
    set tmargin 0
    set bmargin 0
    
    set multiplot
    
    set origin 0.1,1.60
    set size 0.8,0.35
    set key title '{/Helvetica=16 LABELTEXT}'
    plot ....
    set origin 0.1,1.10
    set size 0.8,0.35
    set key title '{/Times=14 LABELTEXT}'
    plot ....
    set origin 0.1,0.60
    set size 0.8,0.35
    set key title '{/Times/Italic=16 LABELTEXT}'
    plot ....
    set origin 0.1,0.10
    set size 0.8,0.35
    set xlabel '{/Helvetica=16 x (mm)}'
    set ylabel '{/Times/Italic=16 S@^{0}_{max} (g/kg)}'
    set key title '{/Helvetica=16 LABELTEXT}'
    plot ....
    
    Use the @ to get the sub and super scripts directly above each other.

Various output options

  • Various things you can set to make nice eps plots
  • set encoding iso_8859_1
    set output 'postscriptoutput.eps'
    set size 1,1
    set origin 0.0,0.0
    

Automatic Reload

  • This is nice if you want to continuously refresh your plot. For example when you are looking to a measurement with continuously storing data in a datafile.
  • create a file called something like 'replot.gpl', and fill it with the following two lines:
    replot
    reread
    
    start gnuplot and initialize your plot the way you want it to look on the screen. Then plot it once, and then load the script.
    #gnuplot
    Terminal type set to 'wxt'
    gnuplot> plot 'test.dat' u 1:2 t '1', '' u 1:3 t '2', '' u 1:4 t '3'
    gnuplot> load 'replot.gpl'
    
    Press Ctrl + C to stop reloading