Getting variables from gnuplot
Sometimes it is useful to get variables
from a gnuplot session steered from python, e.g.
to extract parameters from a fit.
GnuplotBiDir.py
is a test of bidirectional interfacing with gnuplot.
For this you need a really recent
gnuplot
(from CVS) .
The basic usage is
from GnuplotBiDir import Gnuplot
gp=Gnuplot()
gp("a=10")
print "var=",gp.getvar("a")
Remark: for an excellent python interface to
gnuplot see
gnuplot-py
and the interactive add-ons to this
from
IPython.
Mouse clicks
It is now possible (thanks Ethan!)
using the
pause mouse command
to get the coordinates of a mouse-click from python, e.g.
from GnuplotBiDir import Gnuplot
gp=Gnuplot()
gp("set mouse") # activate mouse
gp("plot sin(x)")
print "Now get coordinates of a mouse-click:"
gp("pause mouse 'click with mouse' ")
mouse_x=gp.getvar("MOUSE_X")
mouse_y=gp.getvar("MOUSE_Y")
print mouse_x,mouse_y
This works both interactively, but (more interestingly)
also from a normal python program!
For further details see the test in
GnuplotBiDir.py.
Last modified: 27 October 2004, 16:21:54
Impressum, © Arnd Bäcker