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

Skip to content

Inconsistent image size with savefig(...,type='png') and TkAgg backend #8543

Open
@sorenrasmussen

Description

@sorenrasmussen

Bug report

Closed #8542 and opened this slightly modified version which better illustrates the problem.

Bug summary
When using the TK backend, savefig() with type='png' produces different image sizes, depending on the dpi argument when calling figure().

Code for reproduction

from pylab import *
%matplotlib tk

figsize = (10/3.0, 1)

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

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

Actual outcome

100-300dpi.png is 999x300 pixels.
96-300dpi.png is 1000x300 pixels.

Expected outcome

I would expect both to come out at 1000x300 pixels.

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions