mm441
mm441

Reputation: 495

is there maximum figsize in matplotlib?

I am trying to save a large picture (which is actually larger than resolution of my display), however I get the same size png pictures when increasing figsize. So for two example below I get exactly the same files:

import matplotlib.pylab as plt
fig, ax = plt.subplots(nrows=2, ncols=1, figsize=(10, 100))
ax[0].plot([0, 1], [0, 1])
ax[1].plot([0, 1], [0, 1])
fig.savefig('test1.png')
plt.close()

and second:

fig, ax = plt.subplots(nrows=2, ncols=1, figsize=(10, 150))
ax[0].plot([0, 1], [0, 1])
ax[1].plot([0, 1], [0, 1])
fig.savefig('test2.png')
plt.close()

Is there a way to create a larger picture please?

Upvotes: 6

Views: 7437

Answers (2)

arilwan
arilwan

Reputation: 3993

I work in a Jupyter notebook. What works for me was playing with the dpi argument.

So:

plt.figure(figsize=(25,15)) # small, even for figsize=(150,75)

plt.figure(figsize=(25,15), dpi= 150) # larger

plt.figure(figsize=(25,15), dpi= 300) # largest

Upvotes: 0

mm441
mm441

Reputation: 495

Thanks to @ImportanceOfBeingErnest, indeed the issue was with PyCharm. (I am using 2017.2.3)

Therefore if anyone's having the same issue - just try outside of PyCharm!

Upvotes: 1

Related Questions