I am struggling to figure out how to have stacked subplots in which one subplot shows the data with a 1:1 aspect ratio, the other one doesn't and they both share the x axes. The figure I want looks like this:
My starting point for this figure has been with this code:
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax_top = fig.add_subplot(2, 1, 1)
ax_top.set_aspect(1.0)
x = np.linspace(0, 4*np.pi)
ax_top.plot(x, 5*np.sin(x))
ax_bot = fig.add_subplot(2, 1, 2, sharex=ax_top)
ax_bot.bar([2, 4, 6, 8, 10], [12, 13, 15, 10, 8])
plt.show()
But that produces this:
I would expect the lower plot to have the same width as the upper plot and the matching x ticks line up between the two plots. I've attempted many things to try to coerce this basic figure into the desired figure, but I seem to be missing some fundamental reason it doesn't work.
How might I make my desired figure using matplotlib?



