TracNav
- Home
- Research Overview
- MPhil Information
Research Projects
- Wireless Comms
- Bat System
- Broadband Phone
Visual tags
- Sentient Vehicles
- Task Assignment
- NLMaP
- Computing for the Future of the Planet
- SESAME
- Active Floor
- Open-Source CSK Energy
Development Info
DTG Local Pages
- Cambridge Weather
- Contact Details
Gnuplot Tricks
This page is a repository of collected tricks for graphing data in Gnuplot. An extremely useful Gnuplot tricks page is another must see. Also, the Gnuplot FAQ contains lots of other frequently and not-so frequently asked questions.
- Plotting a function of a datafile column: Fairly intuitive. The things to watch out for are: (i) surround your expression in brackets, (ii) use $i to refer to the i'th column. The following will plot the inverse of the sixth column against the log of the fifth.
plot "myfile.dat" using (1/$6):(log($5))
- Shade certain regions of a graph: export it to SVG using
set terminal svg size 640 480 fname 'Times New Roman' fsize 8
then editing the resulting SVG file in Inkscape, and exporting to PostScript.
- Add labels to particular regions of a graph, or move the key, see the FAQ mentioned above
- Making histograms is not possible, but a perl script that generates the relevant figures is the way forward. There are many different existing ones, talk to Jon, David, or Andy (at least!).
- Generating heat maps from 3-dimensional data is easy with Gnuplot 4.0. See the FAQ mentioned above, which will result in something like
unset key set dgrid3d set hidden3d set pm3d map splot "data.plot" using 1:2:3
Another useful link for pm3d (including how to stop it interpolating to produce non-existant values!) is http://gnuplot.sourceforge.net/demo_4.2/pm3d.html. Note that dgrid3d uses a norm of ALL the input values to define each point (using an inverse-distance weighting). This is unlikely to be what you want if the distribution of your data over the plotting space is uneven! Instead, try:set pm3d map splot "data.plot" using 1:2:3 with points ps 2 pt 5 palette
which gives coloured points (in relation to the actual value of the point). If you unset pm3d map you'll see the points (with their colours) in 3-D.
- Changing the background colour is actually not as difficult as it might seem. You can define a rectangle of appropriate colour, and change the line and border colours to match. You can also change the palette used by pm3d. An example of a heat map with a colour scheme suitable for monochrome printing is:
set obj 1 rectangle behind from graph 0,0 to graph 1,1 set obj 1 fillstyle solid 1.0 fillcolor rgb "black" unset key set pm3d map set border linecolor rgb "black" set palette rgbformulae 30,31,32 set tics out set cbtics in splot "data.plot" using 1:2:3 with p ps 3 pt 5 palette
- Bar charts that are multiple bars per independent variable value can be made with a very flexible bar chart script from Derek Bruening
