Skip to content

New PyGnuplot version !requires code adjustments

Latest
Compare
Choose a tag to compare
@benschneider benschneider released this 29 Sep 21:06
· 4 commits to master since this release

Main changes required in existing code is:

  1. Change import and Figure creation:

Before:
import PyGnuplot as gp
gp.c("plot sin(x))

Now:
from PyGnuplot import gp
fig1 = gp() # or fig1 = gp(r"path to gnuplot")
fig1.a("plot sin(x))

fig2 = gp()
fig1.a("plot sin(x))

fig2 = gp()
fig1.a("plot sin(x))
...

A quick workaround for existing code could be:
from PyGnuplot import gp as gp_class
gp = gp_class()
..
old code here
except gp.s needs to be changed into gp.save

now can create multiple figures, fit and get responses from gnuplot via the ask comment pi = fig1.a('print pi')

What is fixed:

Sometimes Gnuplot was still open in the background, this issue is somewhat addressed.
-> 'Somewhat' because one can still have multiple idle Gnuplot sessions opened in the background if one
overwrites the old gp instance without closing it. -> I.e. the interaction handle gets lost without gnuplot closing.
Fig1 = gp_class() # creates Gnuplot handle 1
Fig1.close() # <- this is needed before re-assigning
Fig1 = gp_class() # creates another Gnuplot handle and overwrites the old one Fig1 variable.

What's Changed

New Contributors

Full Changelog: 0.11.16...0.12.3