Rik's Treehouse > Babbling in Binary > Tips 'n' Tricks > Gnuplot |
Gnuplot is a great scientific plotting program for viewing data and functions on two or three dimensions. The source code is free and compiled binaries are available for a number of platforms.
Problem: Where can I find the latest compiled version of Gnuplot for my platform?
Solution: The latest compiled version can be found at ftp://ftp.gnuplot.vt.edu/pub/gnuplot/. Check out the README for which version to download.
Older Apple Macintosh and Power PC versions of Gnuplot can be found at ftp://ftp.ee.gatech.edu/pub/mac/gnuplot/.
You might also want to check the GnuPlot Beta page if you're still confused.
Problem: Printing is kind of annoying in Gnuplot. First you have to set the terminal type and redirect the output, then plot the graph, and finally reset the terminal and output back to their defaults--a minimum of five commands. Is there a faster way of doing this?
Solution: Yes, you can do this with a single command if you download print.plt. It handles all the terminal and output control so all you have to do is type
and you're done. print.plt is just a standard Gnuplot command file so you can edit as necessary. It is designed for Unix terminals because it pipes the output to the printer via the command set output "|lpr". This probably won't work on a lot of other systems. Also, you need to reset the type of printer if it isn't PostScript.
Problem: Is there a "frequently asked question" (FAQ) page for Gnuplot?
Solution: Yes, it is at http://www.ucc.ie/gnuplot/gnuplot-faq.html. It has lots of good information but it might be a little out of date.
Problem: Is there a way to print multiple plots on the same graph?
Solution: That depends. Version 3.6 supports the command set multiplot which does exactly that and apparently there are some extensions to Gnuplot 3.5 which can also do it but if you want to print to an encapsulated postscript file then there is a shortcut. Just set the terminal and output, and do your plots! They will automatically be overlapped. For example,
will produce the following:
For more complicated graphs you'll want to modify this procedure a bit. Let's say you've got two (fullsize) graphs and you've saved them to command files a.plt and b.plt. To plot them overlapped you need to manually edit the files with a text editor and remove all lines containing set term ..., set output ..., set size ..., and set origin .... Then, in Gnuplot, type
I don't know if this is good style for encapsulated postscript files, but it seems to work! The above procedure may also be handy for use with set multiplot in Gnuplot 3.6.
Problem: Sometimes, when I start up Gnuplot (win32 version) the text font is too small to read. Why is this and how can I fix it?
Solution: You are probably using a font which only accepts particular point sizes. If the selected size is not available (I think) it uses a lookup table to select the best replacement. The lookup table can get confused sometimes so it uses a tiny font. To fix this run Gnuplot and right-click in the command-line area. Select Choose Font... from the menu and pick a new font size that works for you. Don't forget to save your settings by right-clicking again and selecting Update wgnuplot.ini.
gnuplot> load "print.plt"
gnuplot> set term postscript eps
gnuplot> set output 'overlap.ps'
gnuplot> plot x*x t "function"
gnuplot> set size 0.4,0.4 # next plot is 40% of the size
gnuplot> set origin 0.3,0.5 # and shifted 30% right and 50% up
gnuplot> plot 2*x t "derivative"
gnuplot> quit
gnuplot> set term postscript eps
gnuplot> set output 'overlap.ps'
gnuplot> set size 0.5,0.5 # set size and position of a
gnuplot> set origin 0,0.5
gnuplot> load 'a.plt' # plot a
gnuplot> set size 0.5,0.5 # set size and position of b
gnuplot> set origin 0.5,0
gnuplot> load 'b.plt' # plot b
gnuplot> quit
[Rik's Office Hours] [Contact Rik] Last updated: Fri Apr 30 2004, 1:54pm |