8000 [Bug]: Cannot show figure after using PdfPages savefig · Issue #28004 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: Cannot show figure after using PdfPages savefig #28004
Closed as not planned
Closed as not planned
@bwiecek1

Description

@bwiecek1

Bug summary

After figure is saved using PdfPages matplot lib shows error when trying to use figure.show(0:
"AttributeError: Figure.show works only for figures managed by pyplot, normally created by pyplot.figure()"
This is new as it worked fine in matplotlib 3.6.3

Code for reproduction

import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages

r_fig = plt.figure('Results', layout='tight')
r_fig.set_size_inches(8,6)
r_ax1 = plt.subplot(221)
r_ax2 = plt.subplot(222)
r_ax1.plot([1,2,3],[1,2,3])
r_ax2.plot([1,2,3],[2,4,6])

pdff = PdfPages("C:\\Data\\Python\\r_file.pdf")
pdff.savefig(r_fig)
pdff.close()

r_fig.show()

Actual outcome

AttributeError: Figure.show works only for figures managed by pyplot, normally created by pyplot.figure()

Expected outcome

figure shown

Additional information

No response

Operating system

Windows 11

Matplotlib Version

3.8.3

Matplotlib Backend

TkAgg

Python version

3.11.8

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0