Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Labels
Description
Bug summary
Zoom/Pan not working properly in the following PyQt5 example with new version of Matplotlib. (I checked with 3.4.0 and 3.4.3)
Everything works properly with matplotlib 3.3.4 (Check gifs)
Problem occurs only when multiple plots are embedded.
After sometime of switching between figures and zooming/panning following error is shown.
Traceback (most recent call last): File "\lib\site-packages\matplotlib\cbook\__init__.py", line 270, in process func(*args, **kwargs) File "\lib\site-packages\matplotlib\backend_bases.py", line 3074, in _zoom_pan_handler self.release_pan(event) File "\lib\site-packages\matplotlib\backend_bases.py", line 3147, in release_pan ax.end_pan() File "\lib\site-packages\matplotlib\axes\_base.py", line 4239, in end_pan del self._pan_startAttributeError: _pan_start
Thanks
Code for reproduction
importsysimportosfromPyQt5.QtCoreimportQtfromPyQt5.QtWidgetsimportQAbstractItemView,QAction,QApplication,QFileDialog,QInputDialogfromPyQt5.uicimportloadUiTypefrommatplotlib.figureimportFigurefrommatplotlib.backends.backend_qt5aggimport (FigureCanvasQTAggasFigureCanvas,NavigationToolbar2QTasNavigationToolbar)Ui_MainWindow,QMainWindow=loadUiType('window.ui')classMain(QMainWindow,Ui_MainWindow):def__init__(self, ):super(Main,self).__init__()self.setupUi(self)self.fig_dict= {}self.figdata_dict= {}self.mplfigs.itemClicked.connect(self.changefig)fig=Figure()self.addmpl(fig)defchangefig(self,item):text=item.text()text=str(text)self.rmmpl()self.addmpl(self.fig_dict[text])defaddfig(self,name,fig):self.fig_dict[name]=figself.mplfigs.addItem(name)defaddmpl(self,fig):self.canvas=FigureCanvas(fig)self.mplvl.addWidget(self.canvas)self.canvas.draw()self.toolbar=NavigationToolbar(self.canvas,self.mplwindow,coordinates=2)self.toolbar.zoom()self.mplvl.addWidget(self.toolbar)defrmmpl(self,):self.mplvl.removeWidget(self.canvas)self.canvas.close()self.mplvl.removeWidget(self.toolbar)self.toolbar.close()if__name__=='__main__':fig1=Figure()ax1f1=fig1.add_subplot(111)ax1f1.plot([1,2,3,1,2,3])fig2=Figure()ax1f2=fig2.add_subplot(111)ax1f2.plot([100,200,300,400,100,200,300])ax1f2.plot([200,300,400,200,300,400])app=QApplication(sys.argv)main=Main()main.addfig('Oneplot',fig1)main.addfig('Twoplots',fig2)main.show()sys.exit(app.exec_())
Actual outcome
Expected outcome
Operating system
Windows 10 64-bit
Matplotlib Version
3.4.3
Matplotlib Backend
pyqt5
Python version
3.9.7
Jupyter version
No response
Other libraries - window.ui
<?xml version="1.0" encoding="UTF-8"?><ui version="4.0"> <class>MainWindow</class> <widget name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>1280</width> <height>768</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget name="centralwidget"> <layout name="horizontalLayout"> <item> <widget name="mplwindow" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="mouseTracking"> <bool>false</bool> </property> <property name="focusPolicy"> <enum>Qt::ClickFocus</enum> </property> <layout name="mplvl"/> </widget> </item> <item> <widget name="mplfigs"> <property name="sizePolicy"> <sizepolicy hsizetype="Fixed" vsizetype="Expanding"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="minimumSize"> <size> <width>200</width> <height>0</height> </size> </property> <property name="maximumSize"> <size> <width>200</width> <height>16777215</height> </size> </property> <property name="focusPolicy"> <enum>Qt::NoFocus</enum> </property> </widget> </item> </layout> </widget> <widget name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>1280</width> <height>21</height> </rect> </property> </widget> <widget name="statusbar"/> </widget> <resources/> <connections/></ui>
Installation
pip
Conda channel
No response