Skip to content

[Bug]: Cannot show figure after using PdfPages savefig #28004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bwiecek1 opened this issue Apr 1, 2024 · 1 comment
Closed

[Bug]: Cannot show figure after using PdfPages savefig #28004

bwiecek1 opened this issue Apr 1, 2024 · 1 comment

Comments

@bwiecek1
Copy link

bwiecek1 commented Apr 1, 2024

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

@QuLogic
Copy link
Member

QuLogic commented Apr 1, 2024

I believe this is a duplicate of #27865, and fixed by #27869 for the upcoming 3.9.

@QuLogic QuLogic closed this as not planned Won't fix, can't repro, duplicate, stale Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants