inline plot in ipython

1,375 views
Skip to first unread message

Gio Piantoni

unread,
Feb 12, 2015, 1:47:18 PM2/12/15
to pyqt...@googlegroups.com
Hi,

Thanks for the amazing package, it's really fantastic.

I'm trying to plot inline figures with ipython (qtconsole or notebook) and it works well. I implemented my own class and it works fine if I run each command separately but when they are in the same cell the figure is not updated. See attachment ipython_inline.html for an example. Running ipython (2.4.1), pyqt (4.11.2) and QT (4.8.6), pyqtgraph (0.9.10) with python 3.4.2 in a virtualenv in Debian Testing.

How can I update / redraw the figure before writing it inline? I searched for terms like "update" / "redraw" / "flush" / "exec" / "force" in the code and in this forum but I don't know if I should call a function in ipython, qt, pyqt or pyqtgraph.

Thank you!
-g
ipython_inline.html

Luke Campagnola

unread,
Feb 12, 2015, 3:26:28 PM2/12/15
to pyqt...@googlegroups.com
Interesting! I had no idea pyqtgraph could be used with ipython notebook. If you can get this class working reliably then I'd like to add it to pyqtgraph. 

I tried the code you linked to and I get the same result in both cases:
Inline image 1

This is with ipython 2.4.1 and pyqtgraph 0.9.10 as well.
However if I add `QApplication.processEvents()` to the end of `MyFigure.__init__()` then everything seems to work correctly. 


--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/304b9aa7-7989-4a05-bb7b-c32b7a31317d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gio Piantoni

unread,
Feb 13, 2015, 10:08:33 AM2/13/15
to pyqt...@googlegroups.com

Great, I didn't know you could use processEvents as a static method, that's neat. Thanks!

FYI, I modified _repr_png_ so that it can deal with opengl images as well (see attachment)
ipython_inline_gl.html

Merlin von Soosten

unread,
Jun 20, 2015, 8:16:22 AM6/20/15
to pyqt...@googlegroups.com
That looks interesting,
however when I try this my Ipython kernel dies with the message:
QWidget: Must construct a QApplication before a QPaintDevice

How do I do that in the notebook?

Gio Piantoni

unread,
Jun 20, 2015, 9:41:08 AM6/20/15
to pyqt...@googlegroups.com
try:
%gui qt
at the beginning of your notebook / ipython session

Merlin von Soosten

unread,
Jun 20, 2015, 10:31:03 AM6/20/15
to pyqt...@googlegroups.com
Great that did the trick, thanks!
Reply all
Reply to author
Forward
0 new messages