Skip to content

handle repaint requests better it qtAgg #7366

Closed
@tacaswell

Description

@tacaswell

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.py with the qt backend
    • the x-axis does not refresh when it should, resizing or changing focus of the window forces it to update.
  • 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 update is called which (eventually) causes a QPaintEvent to be emitted which triggers the paintEvent method 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.blitbox and self.repaint(...) is called
  • in paintEvent we ignore the input object and (destructively) loop over canvas.blitbox to 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

No one assigned

    Labels

    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGUI: Qt

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions