In a figure consisting of two vertically aligned subplots, is there a way to resize the first subplot, which doesn’t have ticks and labels, so it uses the full width of the figure?
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(2, 1.5), dpi=300)
ax1 = fig.add_subplot(2,1,1, aspect='equal')
ax2 = fig.add_subplot(2,1,2)
ax1.pcolor(np.random.rand(100,500))
ax1.set_xticks([])
ax1.set_yticks([])
ax2.plot(np.arange(0,10), np.random.rand(10), linewidth=1)
ax2.plot(np.arange(0,10), np.random.rand(10), linewidth=1)
Preformatted text