matplotlib multiple plots with different size

import numpy as np
import matplotlib.pyplot as plt 

# generate some data
x = np.arange(0, 10, 0.2)
y = np.sin(x)

# plot it
f, (a0, a1) = plt.subplots(1, 2, gridspec_kw={'width_ratios': [3, 1]})
a0.plot(x, y)
a1.plot(y, x)

f.tight_layout()
f.savefig('grid_figure.pdf')

Here is what the above code is Doing:
1. We create a figure with two subplots, one with a width ratio of 3:1 and the other with a width ratio of 1:3.
2. We plot some data in each subplot.
3. We use f.tight_layout() to automatically adjust the spacing between the subplots.
4. We save the figure to a PDF file.