Preserve explicitly set figure DPI when pickling by scorpi023 · Pull Request #32233 · matplotlib/matplotlib · GitHub
Skip to content

Preserve explicitly set figure DPI when pickling - #32233

Open
scorpi023 wants to merge 1 commit into
matplotlib:mainfrom
scorpi023:fix-32053-figure-dpi
Open

Preserve explicitly set figure DPI when pickling#32233
scorpi023 wants to merge 1 commit into
matplotlib:mainfrom
scorpi023:fix-32053-figure-dpi

Conversation

@scorpi023

Copy link
Copy Markdown

PR summary

Closes #32053
This commit makes set_dpi() update _original_dpi first, then calculates the effective DPI as:
requested DPI × device-pixel ratio
That preserves the user’s DPI choice through pickle round-trips, still behaves correctly on HiDPI displays, and makes savefig(dpi="figure") use the explicitly set DPI.
It also routes SubFigure.set_dpi() through the parent figure’s public setter, so SubFigures follow the same behavior.

Tested normal and HiDPI cases.

AI Disclosure

AI was used for making the change and testing it locally.

PR quality check

  • Use an expressive title, e.g. "Fix title font property precedence"
  • New and changed code is tested
  • [NA] Plotting related features are demonstrated in an example
  • [NA] New features and API changes have release notes
  • [NA] Documentation complies with general and docstring guidelines

@github-actions

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Pickle round-tripping a figure incorrectly restores its original DPI instead of a DPI explicitly changed via Figure.set_dpi().

1 participant