commontk / PythonQt

CMake-ified version of PythonQt
https://mevislab.github.io/pythonqt/
GNU Lesser General Public License v2.1
67 stars 83 forks source link

matplotlib.pyplot.ion() does not work very well #46

Open xhao79 opened 8 years ago

xhao79 commented 8 years ago

When using following code in PythonQt, the plotting window has no interaction, for example, zooming, save figures:

import matplotlib.pyplot as plt
plt.ion()
plt.plot([1,2,3], [1,2,1])
plt.draw()

I even could not close the plotting window with clicking the 'close button' on the title bar.

jcfr commented 8 years ago

Thanks for reporting the problem.

This is most likely explained by the fact plt.draw() creates its own event loop.

An approach would be to subclass an existing matplotlib backend.

While PyQt is different from PythonQt, here are some hints that should apply:

Related docs:

May be you could try:

plt.show(block=False)
jmirabel commented 6 years ago

Hello,

following the advice on that topic, I hit a few bugs but I managed to get a working backend to integrated matplotlib in PythonQt. At its current stage, it is probably not perfect. I have two questions:

jmirabel commented 6 years ago

The code can be found on branch matplotlib of my fork: https://github.com/jmirabel/PythonQt/tree/matplotlib (based on branch patched-6 of this fork).