1. Pyro Gnuplot Interface
to use Gnuplot from within Python:
o Allows the creation of two or three dimensional plots from python. o A gnuplot session is an instance of class 'Gnuplot'. Multiple sessions can be open at once. For example:: g1 = Gnuplot.Gnuplot() g2 = Gnuplot.Gnuplot() Note that due to limitations on those platforms, opening multiple simultaneous sessions on Windows or Macintosh may not work correctly. (Feedback?) o The implicitly-generated gnuplot commands can be stored to a file instead of executed immediately:: g = Gnuplot.Gnuplot('commands.txt') The 'commands.txt' file can then be run later with gnuplot's 'load' command. Beware, however: the plot commands may depend on the existence of temporary files, which will probably be deleted before you use the command file. o Can pass arbitrary commands to the gnuplot command interpreter:: g('set pointsize 2') (If this is all you want to do, you might consider using the lightweight GnuplotProcess class defined in gp.py.) o A Gnuplot object knows how to plot objects of type 'PlotItem'. Any PlotItem can have optional 'title' and/or 'with' suboptions. Builtin PlotItem types: * 'Data(array1)' -- data from a Python list or NumPy array (permits additional option 'cols' ) * 'File('filename')' -- data from an existing data file (permits additional option 'using' ) * 'Func('exp(4.0 * sin(x))')' -- functions (passed as a string, evaluated by gnuplot) * 'GridData(m, x, y)' -- data tabulated on a grid of (x,y) values (usually to be plotted in 3-D) See the documentation strings for those classes for more details. o PlotItems are implemented as objects that can be assigned to variables and plotted repeatedly. Most of their plot options can also be changed with the new 'set_option()' member functions then they can be replotted with their new options. o Communication of commands to gnuplot is via a one-way pipe. Communication of data from python to gnuplot is via inline data (through the command pipe) or via temporary files. Temp files are deleted automatically when their associated 'PlotItem' is deleted. The PlotItems in use by a Gnuplot object at any given time are stored in an internal list so that they won't be deleted prematurely. o Can use 'replot' method to add datasets to an existing plot. o Can make persistent gnuplot windows by using the constructor option 'persist=1'. Such windows stay around even after the gnuplot program is exited. Note that only newer version of gnuplot support this option. o Can plot either directly to a postscript printer or to a postscript file via the 'hardcopy' method. o Grid data for the splot command can be sent to gnuplot in binary format, saving time and disk space. o Should work under Unix, Macintosh, and Windows.
- Relies on the Numeric Python extension. This can be obtained from "SourceForge", http://sourceforge.net/projects/numpy/. If you're interested in gnuplot, you would probably also want NumPy anyway. - Only a small fraction of gnuplot functionality is implemented as explicit method functions. However, you can give arbitrary commands to gnuplot manually:: g = Gnuplot.Gnuplot() g('set data style linespoints') g('set pointsize 5') - There is no provision for missing data points in array data (which gnuplot allows via the 'set missing' command).