Skip to content

Remove old reference to 72 DPI in figure_size_units.py #27794

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 2 commits into from
Feb 17, 2024

Conversation

davidgilbertson
Copy link
Contributor

Remove old reference to 72 DPI

Page for reference: https://matplotlib.org/stable/gallery/subplots_axes_and_figures/figure_size_units.html

PR summary

Removed the outdated note about DPI.

The default DPI for matplotlib inline has been 100 for a while, and with the below test in Jupyter, the saved image is 1000 x 1000 pixels as expected.

%matplotlib inline
import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(10, 10))

ax.plot([1, 2, 3, 2, 3])

fig.savefig('testing.png')

Let me know if this change is a bit aggressive and maybe the text could just be updated to indicate which older versions its a problem in. Or are these guides meant to reflect the current version anyway?

PR checklist

Remove old reference to 72 DPI
@github-actions github-actions bot added the Documentation: examples files in galleries/examples label Feb 15, 2024
@jklymak
Copy link
Member

jklymak commented Feb 15, 2024

I think we still need the comment about bbox_inches=tight as that is a perpetual source of confusion.

@davidgilbertson
Copy link
Contributor Author

@jklymak I couldn't actually work out what that was referring to from the note. I thought it was referring to fig.savefig('testing.png'). Upon further thought I see that it's referring to the image generated for display in the notebook.

So should I just close this, or reword the note, something like:

Unfortunately, this does not work well for the matplotlib inline
backend in Jupyter because it saves the figure
with bbox_inches='tight', which crops the figure and makes the
actual size unpredictable.

And my two cents: "saves the figure" might be clearer as "generates the image" or something like that.

@jklymak
Copy link
Member

jklymak commented Feb 15, 2024

Rewording is what I would do - certainly if the default is no longer 72 dpi we shouldn't say that.

@davidgilbertson
Copy link
Contributor Author

Updated so this now just removes the bit about 72 DPI

@dstansby dstansby added this to the v3.8.4 milestone Feb 17, 2024
@jklymak jklymak merged commit e427499 into matplotlib:main Feb 17, 2024
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation: examples files in galleries/examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants