Matplotlib does not work with pixels directly, but rather with physical dimensions and DPI. If you want to display a shape with a specific pixel size, you need to know the DPI of your monitor. For example, this link will detect this for you.
If you have an image of 3841x7195 pixels, it is unlikely that you will make the monitor so large, so you wonβt be able to display a figure of this size (matplotlib requires that the figure fit on the screen, if you ask for it too large, it will be reduced to screen size). Imagine you want an image of 800x800 pixels for an example. Here's how to show a 800x800 pixel image on my monitor ( my_dpi=96 ):
plt.figure(figsize=(800/my_dpi, 800/my_dpi), dpi=my_dpi)
So, you just split the inch sizes with your DPI.
If you want to keep a figure of a certain size, then this is another matter. Screen DPIs are not that important (unless you ask for a digit that won't fit on the screen). Using the same example of 800x800 pixels, we can save it in different resolutions using the dpi savefig . To save it in the same resolution as on the screen, use only the same dpi:
plt.savefig('my_fig.png', dpi=my_dpi)
To save it as an image of 8000x8000 pixels, use dpi 10 times larger:
plt.savefig('my_fig.png', dpi=my_dpi * 10)
Please note that DPI setting is not supported by all backends. The PNG backend is used here, but the pdf and ps backends will implement the size differently. In addition, changing DPI and size will also affect things like fontsize. A larger DPI will support the same relative sizes of fonts and elements, but if you need smaller fonts to increase your shape, you need to increase the physical size instead of DPI.
Returning to your example, if you want to save an image with 3841 x 7195 pixels, you can do the following:
plt.figure(figsize=(3.841, 7.195), dpi=100) ( your code ...) plt.savefig('myfig.png', dpi=1000)
Note that I used dpi 100 to fit most screens, but saved with dpi=1000 to achieve the required resolution. On my system, this creates png with 3840x7190 pixels - it seems that the DPI is always saved at 0.02 pixels per inch less than the selected value, which will have a (small) effect on large image sizes. A few more discussions of this here .