ax1.plot(dates, list(range(10)))
ax2 = plt.subplot(2, 1, 2, sharex=ax1)
ax2.bar(dates, list(range(10, 20)))
ax1.xaxis.set_major_locator(mticker.MaxNLocator(10))
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
for label in ax1.xaxis.get_ticklabels():
    label.set_rotation(30)
for label in ax2.xaxis.get_ticklabels():
    label.set_rotation(30)
plt.subplots_adjust(hspace=0.35, bottom=0.125)
plt.show()
matplotlib: Creating two (stacked) subplots with SHARED X axis but SEPARATE Y axis values