Skip to content

FIX: pass renderer through _auto_legend_data #29317

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

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

rcomer
Copy link
Member

@rcomer rcomer commented Dec 15, 2024

PR summary

Fixes #29301.

The problem was that FigureCanvasPS._print_figure essentially got into a loop of calling itself: somewhere within figure.draw we needed to call figure._get_renderer in order to calculate the annotation window extent and therefore the legend position. _get_renderer ultimately calls FigureCanvasPS._print_figure again. I haven't quite followed why, but by the time we get to the end of FigureCanvasPS._print_figure, _ps_writer which should contain all the information about the artists is empty.

We can avoid all this by just passing the renderer we already have hold of to get_window_extent.

PR checklist

@rcomer rcomer added this to the v3.10.1 milestone Dec 15, 2024
@rcomer rcomer added the PR: bugfix Pull requests that fix identified bugs label Dec 15, 2024
Copy link
Member

@oscargus oscargus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice test! (I would have went with an image test, but this is clearly better!)

@timhoffm timhoffm merged commit 3aebcb7 into matplotlib:main Dec 16, 2024
42 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Dec 16, 2024
@rcomer rcomer deleted the eps-legend-annotate branch December 16, 2024 09:43
rcomer added a commit that referenced this pull request Dec 16, 2024
…317-on-v3.10.x

Backport PR #29317 on branch v3.10.x (FIX: pass renderer through `_auto_legend_data`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: bugfix Pull requests that fix identified bugs topic: legend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Blank EPS output with legend and annotate
3 participants