[Plot-SIG] ANNOUNCE: New Gnuplot.py (plotting from python using gnuplot)

Michael Haggerty mhagger@blizzard.harvard.edu
Wed, 18 Nov 1998 19:00:13 -0500


Hi,

I would like to announce the release of a major new version of
Gnuplot.py.  Gnuplot.py is an interface between python and the gnuplot
plotting program.  Gnuplot.py can be obtained from

    <http://monsoon.harvard.edu/~mhagger/download>

The module has extensive documentation in the form of comments and
doc-strings within the code, and a simple demonstration can be run by
typing `python Gnuplot.py'.  Of course you must have the gnuplot
program installed to use Gnuplot.py; see
<http://www.cs.dartmouth.edu/gnuplot_info.html> to obtain gnuplot.

This version was inspired and partly derived from an earlier
Gnuplot.py written by Konrad Hinsen, and should be drop-in compatible
with the older version.  However, the new version adds an
object-oriented interface, which is much more flexible than the old
functional interface.  Konrad tells me that he plans to declare the
old Gnuplot.py obsolete and recommend migration to this one.

Example of creating a simple plot using the new interface:

    import Gnuplot
    g = Gnuplot.Gnuplot()         # Start up a gnuplot process
    g.title('Simple plot')        # Can add a title
    g.xlabel('time')              # Can set the x axis label
    g.plot(array, title='Data')   # `array' is an Nx2 array of numbers;
                                  # `Data' goes in the plot's key

Some features and limitations are described below.

Yours,
Michael
--
Michael Haggerty
mhagger@blizzard.harvard.edu

[Taken from Gnuplot.py file comments:]

# Features:
#  +  A gnuplot session is an instance of class `Gnuplot', so multiple
#     sessions can be open at once:
#         g1 = Gnuplot.Gnuplot(); g2 = Gnuplot.Gnuplot()
#  +  The implicitly-generated gnuplot commands can be stored to a file
#     instead of executed immediately:
#         g = Gnuplot.Gnuplot("commands.gnuplot")
#     The file can then be run later with gnuplot's `load' command.
#     Note, however, that this option does not cause the life of any
#     temporary data files to be extended.
#  +  Can pass arbitrary commands to the gnuplot command interpreter:
#         g("set pointsize 2")
#  +  A Gnuplot object knows how to plot three types of `PlotItem':
#     `Data', `File', and `Func'tion.  See those classes for
#     information.
#  +  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
#         for gnuplot to evaluate)
#  +  PlotItems are implemented as objects that can be assigned to
#     variables (including their options) and plotted
#     repeatedly---this also saves much of the overhead of plotting
#     the same data multiple times.
#  +  Communication of data between python and gnuplot is via
#     temporary files, which are deleted automatically when their
#     associated PlotItem is deleted.  (Communication of commands is
#     via a pipe.)  The PlotItems currently in use by a Gnuplot object
#     are stored in an internal list so that they won't be deleted
#     prematurely.
#  +  Can use `replot' method to add datasets to an existing plot.
#  +  Can make persistent gnuplot windows by using the constructor
#     option `persist=1'.  (`persist' is no longer the default.)  Such
#     windows stay around even after the gnuplot program is exited.
#     Note that only newer version of gnuplot support this option.
#  +  Plotting to a postscript file is via new `hardcopy' method,
#     which outputs the currently-displayed plot to either a
#     postscript printer or to a postscript file.
#  +  There is a `plot' command which is roughly compatible with the
#     command from the old Gnuplot.py.
#
# Restrictions:
#  -  Relies on the Numeric Python extension.  This can be obtained
#     from LLNL (See ftp://ftp-icf.llnl.gov/pub/python/README.html).
#     If you're interested in gnuplot, you would probably also want
#     NumPy anyway.
#  -  Probably depends on a unix-type environment.  Anyone who wants
#     to remedy this situation should get in contact with me.
#  -  Only a small fraction of gnuplot functionality is implemented as
#     explicit Gnuplot method functions.  However, you can give
#     arbitrary commands to gnuplot manually; for example:
#         g = Gnuplot.Gnuplot()
#         g('set data style linespoints')
#         g('set pointsize 5')
#     etc.  I might add a more organized way of setting arbitrary
#     options.
#  -  Only 2-d plots are supported so far.
#  -  There is no provision for missing data points in array data
#     (which gnuplot would allow by specifying `?' as a data point).
#     I can't think of a clean way to implement this; maybe one could
#     use NaN for machines that support IEEE floating point.
#  -  There is no supported way to change the plotting options of
#     PlotItems after they have been created.
#  -  The object-oriented interface doesn't automatically plot
#     datasets column-by-column using 1:2, 1:3, 1:4, etc as did the
#     old version of Gnuplot.py.  Instead, make a temporary data file
#     then plot that file multiple times with different `using='
#     options:
#         a = Gnuplot.TemparrayFile(array_nx3)
#         g.plot(Gnuplot.File(a, using=(1,2)), Gnuplot.File(a, using=(1,3)))
#  -  Does not support parallel axis plots, as did the old Gnuplot.py.
#
# Bugs:
#  -  No attempt is made to check for errors reported by gnuplot (but
#     they will appear on stderr).
#  -  All of these classes perform their resource deallocation when
#     __del__ is called.  If you delete things explicitly, there will
#     be no problem.  If you don't, an attempt is made to delete
#     remaining objects when the interpreter is exited, but this is
#     not completely reliable, so sometimes temporary files will be
#     left around.  If anybody knows how to fix this problem, please
#     let me know.

_______________________________________________
Plot-SIG maillist  -  Plot-SIG@python.org
http://www.python.org/mailman/listinfo/plot-sig