PyGnuplot
PyGnuplot copied to clipboard
Close gnuplot (window)
Hello, isn't it possible to close the running gnuplot process via PyGnuplot? By calling it through a subprocess without PyGnuplot it is, but using PyGnuplot I couldn't manage. The background is to implement a routine for me which plots live data and saves a pdf/jpg at request. As seperated scripts both (saving and plotting) can easily be done with PyGnuplot, but whenever I try to do both in one script gnuplot dangles. (I think ending one gnuplot session before the next one will start would fix the issue) Greetings Franz
Yes this is something I wanted to fix.
Hello Sir,
thanks for your answer! I developed a way to fix my issue and use PyGnuplot anyway. By the way: Thanks for your work!
Also on my Win7 / Win8 systems there are no x11 terminals which produces an error when using pg.pdf('example.pdf'). Also the installed pdfcairo doesnt support fsize.
I think you know that all - but to mention it could be helpful.
Best regards
Gesendet: Montag, 20. August 2018 um 03:16 Uhr Von: "Dr. Ben Schneider" [email protected] An: benschneider/PyGnuplot [email protected] Cc: Franzl27 [email protected], Author [email protected] Betreff: Re: [benschneider/PyGnuplot] Close gnuplot (window) (#10)
Yes this is something I wanted to fix.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
You can access the processes via fl. After importing PyGnuplot as gp gp.fl.instance contains all processes and corresponding terminals information you could first close the corresponding plot window 'set term x11 0 close' # where 0 indicates which window to be closed
for example:
import PyGnuplot as gp gp.c('plot sin(x)') # plot sin(x) gp.c('set term x11 "str(gp.fl.n)" close') # close plot window again gp.fl.instance[gp.fl.n][0].terminate() # terminate the process gp.fl.instance.pop(gp.fl.n) # remove process from dictionary gp.default_term = 'x11' # whatever is needed next (wxt, x11, or pdfcairo) gp.figure(gp.fl.n) # start gnuplot process and terminal
you can also always use the gnuplot command to chance to whatever terminal is needed and then use replot to example export a figure into a pdf.
Thx! Exactly what I was looking for. Against all odds it was the right decision to keep using PyGnuplot. Thanks for your great engagement!