-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: record original dpi when dpi set #24674
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
Conversation
Added test that dpi='figure' works as expected. |
This also leaves an inconsistency between |
EDIT: Well again I would not let the user change either of these things post facto However if you want this then we just need to make dpi a property and have a setter |
dpi is already a property, but we read/change/reset it internally so it is a bit messy.
Even if we drop the users ability to set it live, I think we would still want to keep the ability to set the dpi at save time to save multiple resolution versions of the same Figure. |
Oh, definitely. I consider that creation time, as you are creating a new canvas. |
Not always. In matplotlib/lib/matplotlib/figure.py Line 3273 in 1d2abe7
which leads to matplotlib/lib/matplotlib/backend_bases.py Lines 2304 to 2306 in 1d2abe7
which leads to matplotlib/lib/matplotlib/backend_bases.py Lines 2201 to 2207 in 1d2abe7
|
To me, if you are changing the dpi you are essentially making a new canvas. I guess there is a fast path if you don't change the dpi, but that strikes me as so rare as to almost never happen, particularly now in the hiDPI era, where even the figure dpi is not the canvas dpi. |
I'm beginning to remember why I didn't finish doing this fix in this manner. The problem as implemented here is that it doesn't work for HiDPI screens. In that case, the |
I guess I take it from above that we should close this. I'm not quite sure I follow the hiDPI argument - my test machine is high dpi and this works fine, but we can re-open if we decide we want it |
PR Summary
Closes #24644 or at least some of it?
The
figure._original_dpi
is used when we want to print usingdpi='figure'
. However, if we manually set the dpi viafigure.set_dpi
this doesn't get set and the figure is saved at the origin figure dpi.Example
On main,
Boo.png
has 100 dpi, whereas after this change it has 150 dpi.Caveat.
This doesn't completely fix
set_dpi
, which doesn't respect deviceRatio when it is called, so hiDPI screens don't double the size and resolution of the figure.PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst