Repository navigation
Closed
Labels
Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueshttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGUI: Qt
Milestone
Description
To help us understand and resolve your issue please check that you have provided
the information below.
- Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)
- v2.x, 3.5.2, linux
- How did you install Matplotlib and Python (pip, anaconda, from source ...)
- anaconda for deps, source for mpl
- If possible please supply a Short, Self Contained, Correct, Example
that demonstrates the issue i.e a small piece of code which reproduces the issue
and can be run with out any other (or as few as possible) external dependencies.- run
python examples/animation/strip_chart_demo.pywith the qt backend - the x-axis does not refresh when it should, resizing or changing focus of the window forces it to update.
- run
- If this is a regression (Used to work in an earlier version of Matplotlib), please
note where it used to work.- works correctly with tkagg backend
What I think is going on is:
- on draw, the full figure is re-rendered to the mpl side buffer and
updateis called which (eventually) causes aQPaintEventto be emitted which triggers thepaintEventmethod which copies data from the mpl side to the display buffers. - in animation with blitting on each frame the 'base' image is used as a base and just the artist(s) of interest are re-rendered, the bounding box to re-draw is added to
canvas.blitboxandself.repaint(...)is called - in
paintEventwe ignore the input object and (destructively) loop overcanvas.blitboxto selectively update sub-regions of the displayed image. - in this example due to the event generator running as fast as it can, there is always an entry in
canvas.blitbox, thus the full buffer never gets copied to the screen and we are left with incorrect labels on the x-axis (despite the mpl-side buffer being correct) - anything that slips a paint in between the animation events (ex changing focus, resizing) will 'fix' this temporarily.
The object which comes into paintEvent is a QPaintEvent object which has a region attached to it (http://doc.qt.io/qt-4.8/qpaintevent.html#region assume it is the same for qt5), we should be using that rather than our canvas.blitbox side-band. Each blit calls repaint which will in turn generate a QPaintEvent object (which will in turn fall through paintEvent) thus the loop over canvas.blitbox is redundant with many calls to this function.
attn @anntzer @mfitzp @pwuertz as people who were have been involved in the qt backend and the most recent re-factor.
Metadata
Metadata
Assignees
Labels
Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issueshttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGUI: Qt
Activity
anntzer commentedon Oct 31, 2016
As you suggested, a patch as simple as
does solve the issue.
The question that remains is whether I have a way to know, while within
paintEvent(), whether a normal repaint or a blitting paint was requested?A comparison with other backends gives the following:
canvas.blit(without going through the event loop) so all is well.self._bbox_queuefor the same purpose) but I can't test it :-) I currently gettacaswell commentedon Oct 31, 2016
A better question is do we really care if it is a normal draw or a blit? In either case we are just moving values from the agg renderer to the qt screen buffer and I think that the two code paths are functionally equivalent (except the len == 0 case seems to deal with byte order better?) and the second one seems to either properly deal with / expose a pyside bug in reference counting.
I strongly suggest the answer is we do not care and those code blocks could be unified.
My dim recollection is that
paintEventused to callagg.draw()and that got cleaned up recently.anntzer commentedon Oct 31, 2016
The main difference between normal draws and blits is that normal draws additionally call
painter.eraseRecton the canvas first, whereas blits don't. I don't know at what level transparency is handled, and whether this can be an issue.FIX: properly mix blitting + redraw in Qt4Agg/Qt5Agg
FIX: properly mix blitting + redraw in Qt4Agg/Qt5Agg
anntzer commentedon Sep 14, 2018
Closed by #8951