Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Inconsistent image size with savefig(...,type='png') #8542

Closed
@sorenrasmussen

Description

@sorenrasmussen

Bug report

Bug summary

savefig() with type='png' produces different image sizes, depending on the dpi argument when calling figure().

Code for reproduction

from pylab import *
%matplotlib tk

plt.figure(figsize=(1,1),dpi=100)
plt.savefig("100-300dpi.png",type="png",dpi=300)

plt.figure(figsize=(1,1),dpi=96) #96 is my screen DPI
plt.savefig("96-300dpi.png",type="png",dpi=300)

Actual outcome

100-300dpi.png is 654x300 pixels.
96-300dpi.png is 681x300 pixels.

Expected outcome

I would expect both to come out at 300x300 pixels, or at least equal size.

Matplotlib version

  • Matplotlib 2.0.0
  • Python 2.7.13
  • IPython 5.1.0
  • Jupyter Version: 4.4.1
  • Platform: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions