...
# annotate some points:
ax.annotate("100th data point", (days[100], values[100]), xytext=(days[100], values[100]-1000),
arrowprops=dict(arrowstyle="->", connectionstyle="angle3,angleA=0,angleB=-90"))
ax.annotate("200th data point", (days[200], values[200]), xytext=(days[200], values[200]-1000),
arrowprops=dict(facecolor='black', shrink=0.05))
# didn't use any arrow styles (just to show how it should look like)
ax.annotate("300th data point", (days[300], values[300]))
plt.show()
fig, ax = plt.subplots(figsize=(15, 15))
dummy2019.plot(ax=ax)
for index, row in dummy2019.iterrows():
if type(row['Feestdag']) is str:
datum = index
aantal = row['Aantal']
feestdag = row['Feestdag']
ax.annotate(feestdag, xy=(index, aantal), xycoords='data',
xytext=(80, -30), textcoords='offset points',
arrowprops=dict(arrowstyle="->",
connectionstyle="arc3,rad=-0.2"))
您可以使用
ax.annotate()
方法。以下是一个完整的示例:它生成了这个图:
现在,让我们在图中注释一些点。我们可以在
plt.show()
之前使用ax.annotate()
方法来实现这一点,如下所示:这将生成以下图表:
使用
ax.annotate()
很容易。。。以下是我使用的参数:有关更多信息,请查看official documentation中的
ax.annotate()
感谢@Anwarvic!我找到了问题的解决方案!我做了这个循环(使用ax.annotate)以使其自动更新
相关问题 更多 >
编程相关推荐