The following python
script is given an image as input and shows it 8 times in a single pdf
page:
pdf = PdfPages( './test.pdf' )
gs = gridspec.GridSpec(2, 4)
ax1 = plt.subplot(gs[0])
ax1.imshow( _img )
ax2 = plt.subplot(gs[1])
ax2.imshow( _img )
ax3 = plt.subplot(gs[2])
ax3.imshow( _img )
# so on so forth...
ax8 = plt.subplot(gs[7])
ax8.imshow( _img )
pdf.savefig()
pdf.close()
The input image can have different size (unknown a priori). I tried using the function gs.update(wspace=xxx, hspace=xxx)
to change the spacing between the images, hoping that matplotlib
would automagically resize and redistribute the images to have least white space possible. However, as you can see below, it didn't work as I expected.
Is there a better way to go to achieve the following?
- Have images saved with max resolution possible
- Have less white space possible
Ideally I would like the 8 images to completely will the page size of the pdf
(with minimum amount of margin needed).
Aucun commentaire:
Enregistrer un commentaire