我有以下一段代码
import matplotlib.pyplot as plt
import numpy as np
[...]
def display(self):
t = self.stateLabels
fig, axs = plt.subplots(4, 1, sharex=True)
fig.subplots_adjust(hspace=0)
axs[0].plot(t, self.production)
axs[0].title.set_text('Production')
axs[0].frameon = True
axs[1].plot(t, self.consumption)
axs[1].title.set_text('Consumption')
axs[2].plot(t, self.investment)
axs[2].title.set_text('Investment')
axs[3].plot(t, self.gdp)
axs[3].title.set_text('GDP')
plt.show()
这将创建以下图表:
我想在轴上添加垂直线,以使该图看起来像这样:
有可能做到吗?如果是,怎么办?