8000 Saving issue with pdf backend · Issue #17599 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Saving issue with pdf backend #17599
Closed
@ericpre

Description

@ericpre

Bug report

Bug summary

The animated artists are missing when saving a figure with the pdf backend (matplotlib 3.0.0 and more recent). The png backend is working fine.

Code for reproduction

# Paste your code here
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 2 * np.pi, 100)

fig, ax = plt.subplots()

(ln,) = ax.plot(x, np.sin(x), animated=True)
plt.show(block=False)
plt.pause(0.1)

bg = fig.canvas.copy_from_bbox(fig.bbox)
ax.draw_artist(ln)
fig.canvas.blit(fig.bbox)

plt.savefig('Trial.pdf')

Actual outcome

image

Expected outcome
image

Saving using the following works fine:

# This is working fine
from matplotlib.backends.backend_pdf import PdfPages
with PdfPages('Trial.pdf') as pdf:
     pdf.savefig()

Matplotlib version

  • Operating system: linux
  • Matplotlib version: 3.0.0 and above
  • Matplotlib backend (print(matplotlib.get_backend())): 'Qt5Agg'
  • Python version: 3.7.7
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0