annotate a plot using matplotlib

前端 未结 1 1168
梦如初夏
梦如初夏 2020-12-03 05:31

I am using this to making a plot with contains in specific moment something such as highlight

plt.axis(\'normal\')
plt.axvspan(76, 76, facecolor=\'g\', alpha         


        
相关标签:
1条回答
  • 2020-12-03 06:14

    Here's how you can have an arrow showing to the span:

    import matplotlib.pyplot as plt
    
    plt.axvspan(76, 76, facecolor='g', alpha=1)
    plt.annotate('This is awesome!', 
                 xy=(76, 0.75),  
                 xycoords='data',
                 textcoords='offset points',
                 arrowprops=dict(arrowstyle="->"))
    plt.show()
    

    For more info about annotate see docs.

    The output of the above code: enter image description here

    0 讨论(0)
提交回复
热议问题