Your question also raises the question:
- When you write
How can I get the coordinates of the box displayed in the following plot? What coordinate system do you mean?
By default, annotate is executed using xytext = None, defaults to xy, and if textcoords = None, defaults to xycoords .
Since you did not specify a coordinate system. Your annotation is on the system by default. You can specify the coordinates of the data, which are good enough for some purposes:
x = ax.annotate('text', xy=(0.5, 0), xytext=(0.0,0.7), ha='center', va='bottom', textcoords='data', xycoords="data", bbox=dict(boxstyle='round', fc='gray', alpha=0.5), arrowprops=dict(arrowstyle='->', color='blue'))
To find the coordinate system, you can:
In [39]: x.xycoords Out[39]: 'data'
and get the coordinates:
In [40]: x.xytext Out[40]: (0.0, 0.7) In [41]: x.xy Out[41]: (0.5, 0)
PS is not directly connected, but exiting IPython , if you are still not using it, it can improve Python development efficiency and use matplotlib. Give it a try.