Skip to content

[Bug]: dpi='figure' option no longer working in savefig #26252

Closed as not planned

Description

@astrofrog

Bug summary

The default dpi='figure' option in savefig no longer appears to work correctly - instead the DPI is a fixed value.

Code for reproduction

import matplotlib.pyplot as plt

fig = plt.figure()
fig.set_dpi(10)
ax = fig.add_subplot(1, 1, 1)
fig.savefig("test_dpi.png", dpi="figure")

Actual outcome

A 100 DPI figure:

test_dpi

Expected outcome

A 10 DPI figure:

test_dpi

Additional information

I bisected this and it appears to have been introduced in #19126 - prior to this, it worked fine.

Operating system

All platforms

Matplotlib Version

Bug first appeared in Matplotlib 3.5

Matplotlib Backend

MacOS X and Agg

Python version

3.11 but seen in other Python versions

Jupyter version

No response

Installation

pip

Activity

  1. astrofrog commented on Jul 4, 2023

    @astrofrog
    ContributorAuthor

    This might be a duplicate of #24644? If so, sorry for the noise! However I wonder if it makes sense to put in a deprecation warning soon in set_dpi if it's going to be removed, so that other users don't get caught out?

  2. tacaswell commented on Aug 11, 2023

    @tacaswell
    Member

    I'm going to close this in favor of tracking this is #24644, but I do not think we should consider Figure.set_dpi as a candidate for deprecation!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions