Description
Bug report
Bug summary
For a number of years, I have been maintaining an interactive application that embeds subclassed FigureCanvasQT objects within a PyQt application. Up until Matplotlib v3.0.3., it was possible to create standard Matplotlib PyQt figures, i.e., using plt.figure
within an embedded IPython shell, that coexist with the subclassed canvas objects. Now in Matplotlib v3.1.0, a call to plt.figure()
destroys all the other canvas objects.
Unfortunately, I cannot debug this within Visual Studio since I am currently unable to install Matplotlib from the source. By going through the new_figure_manager
code line by line, I can confirm that the windows are destroyed when calling FigureCanvasQT.__init__(figure)
, but not when calling FigureCanvasBase.__init__(figure)
, but I can't work out what triggers the destruction of the other windows. I presume the subclassed canvasses are not being registered somewhere, and pyplot
assumes they are no longer active, but I am hoping someone will show me where to look. This may not be a Matplotlib bug, but it's certainly an unwelcome side effect in my application.
Code for reproduction
If you have nexpy
installed (pip install nexpy
) and launch it, you can reproduce this from within the embedded IPython shell with the following, which creates a new subclassed window and then attempts to open a regular pyplot
window.:
In [1]: new_window=NXPlotView()
In [2]: plt.get_fignums()
Out[2]: [1, 2]
In [3]: plt.figure()
There are two figure numbers, because NeXpy automatically creates a window with a figure number of 1 when it is launched.
Actual outcome
A new window with an updated figure number is created but all other windows not created by pyplot
are destroyed.
In [4]: plt.get_fignums()
Out[4]: [3]
Expected outcome
In Matplotlib v3.0.3, a new pyplot
window is created by the PyQt5 backend without destroying anything else.
In [4]: plt.get_fignums()
Out[4]: [1, 2, 3]
Matplotlib version
- Operating system: Mac OS v10.14.5
- Matplotlib version: 3.1.0
- Matplotlib backend: Qt5Agg
- Python version: 3.7.2
- Jupyter version (if applicable): 1.0.0
- Other libraries: