【发布时间】:2020-10-25 07:24:09
【问题描述】:
我有以下代码片段:
data.plot(y='Close', ax = ax)
newdates = exceptthursday.loc[start:end]
for anotate in (newdates.index + BDay()).strftime('%Y-%m-%d'):
ax.annotate('holliday', xy=(anotate, data['Close'].loc[anotate]), xycoords='data',
xytext=(-30, 40), textcoords='offset points',
size=13, ha='center', va="baseline",
bbox=dict(boxstyle="round", alpha=0.1),
arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.1));
正如您所看到的,我已经明确提到了xytext,这使得“气泡”变得混乱,因为它们在某些位置重叠,难以阅读。有什么办法可以“自动放置”以使它们不重叠。比如一些“气泡”在情节线的上方和下方,它们不重叠。
【问题讨论】:
-
您可以发布示例数据框吗?
-
@bigbounty 我使用来自
web.DataReader('fb', 'yahoo')的数据这是来自from pandas_datareader import data as web的数据
标签: python python-3.x pandas matplotlib annotations