【问题标题】:Arrow not showing in pandas plot大熊猫图中未显示箭头
【发布时间】:2019-02-14 20:56:48
【问题描述】:

enter image description here我的情节需要一个箭头,我试图插入但它不会显示。我进行了研究,但找不到我做错了什么。

ax_google = df_stocks['GOOG'].plot(linewidth=5, color= "k", figsize=(9, 6))
ax_google.set_title("GOOGLE prices development", size=16, weight='bold')
ax_google.set_xlabel('Date')
ax_google.set_ylabel("Index")
ax_google.legend(['GOOG'])
ax_google.set_ylim(0,400)
ax_google.set_xlim('2008-01-01', '2010-01-01');
arrow = {'facecolor':'black', 'width':2, 'shrink':0.05}
ax.annotate('Bankruptcy of Lehman Brothers', xy=('2008-09-15',245), xytext=('2009-06-06',325), arrowprops=arrow);

【问题讨论】:

  • 你能包括你得到的情节并显示你想要箭头的位置吗?

标签: python pandas matplotlib plot


【解决方案1】:

据我所知,您的代码似乎没有设置轴。

轴是图形上的一种框架。您可以在Matplotlib website 上找到图片。 但是,您需要创建一个子图:

fig, ax_google = plt.subplots(figsize=(9,6)) #using ax_google instead of ax
ax_google.plot("GOOG",data=df_stocks,linewidth=5, color= "k")

然后继续你的代码。

我无法检查这是否有效,因为我没有数据。 希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-03
    • 2016-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多