2

I use code as below to plot graphs and save fig to png files, but all png files are not in the same size (width x height), how can I let all of them in the same size?

fig, ax = plt.subplots(nrows=1, ncols=1, figsize(20, 10))
fig.savefig('myImage.png', bbox_inches='tight', dpi=300)

The png files size (width x height) as below, does anyone help me?

enter image description here

7
  • did you try setting figsize in subplots? Commented May 3, 2024 at 6:57
  • do you mean that I have to set figsize = (20, 10) for fixed 6000 x 3000 when dpi is 300? Commented May 3, 2024 at 7:33
  • I am doing some trial and error with different image types. Compression seems to be the main issue... Commented May 3, 2024 at 7:39
  • I only use for png image. Commented May 3, 2024 at 7:54
  • See my answer, I mistook resolution for file size... Commented May 3, 2024 at 8:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.