Zoom rubber band is smooth in small window. But when I increase the size of the window the performance degrades.
Here I have stretched the window across two monitors for illustration.
Code for reproduction
importmatplotlib.pyplotaspltimportnumpyasnp# Data for plottingt=np.arange(0.0, 2.0, 0.01)
s=1+np.sin(2*np.pi*t)
fig, ax=plt.subplots()
ax.plot(t, s)
ax.set(xlabel='time (s)', ylabel='voltage (mV)',
title='About as simple as it gets, folks')
ax.grid()
fig.savefig("test.png")
plt.show()
@anntzer you introduced _unmultiplied_rgba8888_to_premultiplied_argb32 in #11845, and the original issue says maybe it was an issue with qt5.1 and earlier. Given that qt5.2 is now 9 years old do we need to support 5.1 any longer and maybe this function isn't required?
Activity
QuLogic commented on Sep 20, 2022
How large is large enough to be slow?
inxp commented on Sep 21, 2022
The GIF that I posted is a window stretched over two 24" monitors, each having 1920x1080 resolution.
For me, the lag becomes noticeable in a 1920x1080 window.
Note that the same lag does not exist or is very low in the matplotlib 2.2.5 version with the Qt5Agg backend.
There is no lag in TkAgg backend for any window size.
Please try comparing the performance of rubber band in the following code between Matplotlib version 2.2.5 and 3.6.0.
import sys from PyQt5.QtWidgets import QWidget, QApplication, QPushButton, QVBoxLayout from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar import matplotlib.pyplot as plt import random class Window(QWidget): def __init__(self, parent=None): super(Window, self).__init__(parent) self.figure = plt.figure() data = [random.random() for i in range(10)] ax = self.figure.add_subplot(111) ax.plot(data, '*-') self.canvas = FigureCanvas(self.figure) self.toolbar = NavigationToolbar(self.canvas, self) self.canvas.draw() layout = QVBoxLayout() layout.addWidget(self.toolbar) layout.addWidget(self.canvas) self.setLayout(layout) if __name__ == '__main__': app = QApplication(sys.argv) main = Window() main.showMaximized() sys.exit(app.exec_())inxp commented on Dec 11, 2022
Update
On further testing, I found that lag is there even when dragging legends.
So I checked paintEvent function in FigureCanvasQTAgg of \backends\backend_qtagg.py
The delay was mainly due to following statement in _unmultipled_rgba8888_to_premultiplied_argb32 function of cbook\__init__.py
_unmultipled_rgba8888_to_premultiplied_argb32 function is called by paintEvent function
The function call was added as part of #11845 commit.
On reverting the changes done in commits #11731 and #11845, The lag was gone. Everything is working as expected.
So I think, as window size increases it takes more time for np.take statement causing delay between subsequent paints.
Am I doing something wrong?
jklymak commented on Dec 11, 2022
@anntzer you introduced _unmultiplied_rgba8888_to_premultiplied_argb32 in #11845, and the original issue says maybe it was an issue with qt5.1 and earlier. Given that qt5.2 is now 9 years old do we need to support 5.1 any longer and maybe this function isn't required?