Request: Set figure size in pixels, not inches

Working with inches is counter-intuitive in my work flow, and I’m pretty sure it is for many people.

For example, I often generate a figure and save it using the GUI. The saved png thus have a nice resolution of 2400×1220. Now I want to automate the saving but have to translate this pixel resolution to inches and dpi, which I have no clue.

Google is full of questions about this. Most answers suggest calculating the size in inches using a dpi value and the pixel size. Why not integrate this directly in matplotlib?

This wiki page explain the usage of set_figsize_inches(). Setting the figure size in inches //does// require having a dpi value somewhere. I think having a set_figsize_pixels() would be really useful.


Author: Fantashit

2 thoughts on “Request: Set figure size in pixels, not inches

  1. Just to add, the wiki page suggests using set_figsize_inches() which does not exists. The actual function name is set_size_inches()

    For example, here’s how I’ve done it:

    fig = gcf()
    DPI = fig.get_dpi()

Comments are closed.