Dear PyMOL users,

I would like to plot a graph by means of matplotlib library and call it 
from PyMOL as a separate Tkinter (Tk) window. It seems that this task is 
not simple, since the it requires several threads as well as some tune 
adjustment of matplotlib/Tk 
(https://github.com/speleo3/pymol-psico/blob/master/psico/matplotlib_fix.py). 
Matplotlib offers a so-called interactive mode, which I implemented in 
the simplified example below. This code works well on Windows if I 
install it as a plugin. In contrast, it crashes on Mac and also when I 
run it from the cmd with command "run".

Question: How to create a new Tk window/thread in the PyMOL session and 
output matplotlib graph on it?

from pymol import cmd, stored
from Tkinter import *
import numpy
import matplotlib
matplotlib.use('TkAgg')

class Plotter:
     def plotDistances(self, x, y):
         plt.figure()
         plt.plot(x, y, 'o')
         plt.tight_layout()
         plt.ion()
         plt.show()

graph1 = Plotter()
xtest = numpy.linspace(1, 300, 300)
ytest = numpy.linspace(1, 300, 300)
graph1.plotDistances(xtest,ytest)

-- 
Dinar Abdullin
PhD student
Institut fuer Physikalische und Theoretische Chemie
Wegelerstr. 12
D-53115 Bonn
Tel.: +49(0)228-732572   Fax: +49(0)228-732073
E-Mail: abdul...@pc.uni-bonn.de
WWW: http://www.schiemann.uni-bonn.de/


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Reply via email to