【发布时间】:2020-07-03 17:10:38
【问题描述】:
鉴于以下代码部分:
fig, (ax1, ax2) = plt.subplots(2, 1)
num = sto_list.gt(70).sum(1)
plt.yticks(fontsize = 25)
df2 = web.DataReader('fb', 'yahoo', start, end)
ax = num.plot(figsize=(45,25), ax=ax2, color = 'Red')
df2.plot(y = 'Close', figsize=(45,25), ax=ax1, color = 'Green')
ax.grid()
ax1.xaxis.label.set_visible(False)
ax.xaxis.label.set_visible(False)
底部的子图是从num绘制的:
num
Out[70]:
Date
2015-07-06 33
2015-07-07 20
2015-07-08 4
2015-07-09 8
2015-07-10 8
..
2020-06-29 14
2020-06-30 13
2020-07-01 18
2020-07-02 20
2020-07-03 28
Length: 1228, dtype: int64
我想要做的是在小于 10 的地方绘制一条直线:
plt.axvline(x=num.lt(10), ax = ax2)
虽然我无法绘制线。这样做的最佳方法是什么?
【问题讨论】:
标签: python python-3.x pandas matplotlib annotations