Skip to content

Why does setting imshow(animated=True) still show an image? #18985

Open
@thomasaarholt

Description

@thomasaarholt

Bug report

Bug summary
Setting animated=True during a plot call is supposed to make matplotlib artists not be drawn unless explicitly called. Source

With plt.plot([1,2,3], animated=True), calling plt.show() shows an empty axes.
However, plt.imshow([[1,2],[3,4], animated=True) does show an image.

I observe this behaviour with both the qt5 and tk backends.
Have I misunderstood something? Or is this a discrepancy?

Code for reproduction

Here is a full example:

import matplotlib.pyplot as plt
import numpy as np
fig, (ax1, ax2) = plt.subplots(ncols=2)
imdata = np.random.random((20,20))
lndata = imdata[0]
im = ax1.imshow(imdata, animated=True)
(ln,) = ax2.plot(lndata, animated=True)
plt.show()

Actual outcome
Image plotted after calling code

Expected outcome
Two blank axes.

Matplotlib version

  • Operating system: Win 10
  • Matplotlib version: 3.1.3
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.8
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions