How can I keep the shape size using matplotlib, although using pyplot.show ()?

Have a look at the following python example:

import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams['figure.figsize'] = [8.27, 11.69]
fig = plt.figure()
plt.show() # This line causes problems with figsize
fig.savefig('test.pdf')

If I use "plt.show ()" the size of the test.pdf figure changes a lot (from

  • 210 x 297 [mm] to
  • 213 x 250 [mm]

What do I need to do to keep it constant?

+3
source share
1 answer

There is a good demo on adjusting image size in matplotlib shapes on a SciPy site .

show() , matplotlib . , TkAgg ( ), 12 . WXAgg, .

, , show(), . , , , .

, , reset pdf. :.

fig.set_size_inches(8.27, 11.69)
fig.savefig('test.pdf')
+6

All Articles