xytext details in Matplotlibs Annotate

后端 未结 1 1146
抹茶落季
抹茶落季 2021-01-25 05:04

With the following code I am plotting a candlestick graph and also make use of annotations. I have played arround until I found the right positions for the text, but I still don

相关标签:
1条回答
  • 2021-01-25 05:45

    You chose to have the text coordinates in offset points. E.g. xytext=(-17, 20) places the text at 17 points to the left and 20 points to the top from the point which you annotate.

    The coordinates may be more obvious when changing the horizontalalignment to "center" in the annotation. annotate( ... , ha="center").

    You can then get the result by setting the x coordinate to 0.

    ax1.annotate('Long', xy=(stock_data['Date'][10], stock_data['Low'][10]),
                     xytext=(0, -27),
                     textcoords='offset points', ha="center",
                     arrowprops=dict(facecolor='grey', color='grey'))
    
    0 讨论(0)
提交回复
热议问题