jupyter/qtconsole

Matplotlib interactive figures no longer automatically redraw when updated

bcolsen opened this issue · 4 comments

I have found that with 5.3.2 that the interactive figure backends (qt and tk) no longer automatically redraw when updated on subsequent lines or titles. This also affects in Spyder when trying to update interactive figures as well.

I'm currently running Ubuntu 20.04

Jupyter QtConsole 5.3.2
Python 3.9.9 | packaged by conda-forge | (main, Dec 20 2021, 02:41:03) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.31.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %matplotlib qt5 
   ...: import matplotlib.pyplot as plt
   ...: plt.plot([1,2,3])
Out[1]: [<matplotlib.lines.Line2D at 0x7f5f3056f5b0>]

In [2]: plt.plot([2,3,4])  #  The new line is not plotted in the figure
Out[2]: [<matplotlib.lines.Line2D at 0x7f5f300b8ac0>]

In [3]: plt.draw()  # Now the new line appears

The new line will also appear if the plot in redrawn by interacting with it (zooming, panning or resizing the window)

Jupyter QtConsole 5.1.1
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50) 
Type 'copyright', 'credits' or 'license' for more information
IPython 8.6.0 -- An enhanced Interactive Python. Type '?' for help.

%matplotlib qt5
import matplotlib.pyplot as plt
plt.plot([1,2,3])
Out[1]: [<matplotlib.lines.Line2D at 0x7f9bac2e7c70>]

plt.plot([2,3,4])  #  Updates the figure with the new line
Out[2]: [<matplotlib.lines.Line2D at 0x7f9bac2754c0>]

I was just made aware that there was a new version released yesterday.

I tested it with new packages in a clean environment and it work just like it should. It looks like this is fixed!

Now I need to get it to work in Spyder.

Jupyter QtConsole 5.4.0
Python 3.11.0 | packaged by conda-forge | (main, Oct 25 2022, 06:18:27) [GCC 10.4.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.6.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR
   ...: print("Qt: v", QT_VERSION_STR, "\tPyQt: v", PYQT_VERSION_STR)
Qt: v 5.15.6 	PyQt: v 5.15.7

In [2]: import matplotlib
   ...: matplotlib.__version__
Out[2]: '3.6.1'

In [3]: %matplotlib qt5
   ...: import matplotlib.pyplot as plt
   ...: plt.plot([1,2,3])
Out[3]: [<matplotlib.lines.Line2D at 0x7ff96c104a10>]

In [4]: plt.plot([2,3,4])
Out[4]: [<matplotlib.lines.Line2D at 0x7ff969e5ca90>]

In [5]: 

I think the problem is with IPykernel @bcolsen. Please update it to its latest version (6.16.2 or at least 6.16.1) in your Spyder env and try again.

I did a clean install to a new environment and it gave me IPykernel 6.17 and the plot updating working in Spyder now. Thanks for the help.

Great! I'm really glad it's working for you now.