I would like to create a summary A4 page for the results of some computations I have done.
These include both images and plot in a layout like the one the code below produces. Unfortunately, matplotlib makes the images very small and the plots very wide.
How can I make everything align nicely in a 2x6 grid, as in images are displayed square and plots have shape 1x2 and save it in portrait orientation?
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
mpl.use('pdf')
img = np.random.standard_normal((20,20))
data = np.linspace(0,1,10000)
title_fontsize = 'x-small'
fig = plt.figure()
fig.figsize = (6*5, 2*5)
ax = np.zeros(8, dtype=object)
gs = fig.add_gridspec(8, 2, width_ratios=[1,1])
ax[0] = fig.add_subplot(gs[0, 0])
ax[1] = fig.add_subplot(gs[0, 1])
ax[2] = fig.add_subplot(gs[1:3, :])
ax[3] = fig.add_subplot(gs[3, :])
ax[4] = fig.add_subplot(gs[4, 0])
ax[5] = fig.add_subplot(gs[4, 1])
ax[6] = fig.add_subplot(gs[5, :])
ax[7] = fig.add_subplot(gs[6, :])
ax[0].imshow(img)
ax[0].set_title('Covariance Operator', fontsize = title_fontsize)
ax[1].imshow(img)
ax[1].set_title('Sample', fontsize = title_fontsize)
ax[2].imshow(img)
ax[2].set_title('Truth', fontsize = title_fontsize)
ax[3].plot(data)
ax[3].set_title('Measurement', fontsize = title_fontsize)
ax[4].imshow(img)
ax[4].set_title('MCMC Reconstruction', fontsize = title_fontsize)
ax[5].imshow(img)
ax[5].set_title('FBP Reconstruction', fontsize = title_fontsize)
ax[6].plot(data)
ax[6].set_title('Heightscale', fontsize = title_fontsize)
ax[7].plot(data)
ax[7].set_title('Jump Size', fontsize = title_fontsize)
for x in ax.flat:
for tick in x.xaxis.get_major_ticks():
tick.label.set_fontsize('xx-small')
for tick in x.yaxis.get_major_ticks():
tick.label.set_fontsize('xx-small')
plt.savefig('test.pdf')
For reference, this is how the output looks like now: