I wonder if it is possible that with matplotlib, we can draw the x/y axis labels of the image. In other words, how to insert a text inside an arrow line?
I wonder if it is possible that with matplotlib, we can draw the x/y axis labels of the image. In other words, how to insert a text inside an arrow line?
As far as I know, drawing with matplotlib can be achieved by overlaying arrows and text annotations. You may be able to do this in other ways.
import matplotlib.pyplot as plt
from matplotlib import patches
fig, ax = plt.subplots()
ax.plot([],[])
ax.set_xlim(0,10)
ax.set_ylim(0,4)
xy1, xy2 = (0,-0.15), (1,-0.15)
txt_pos = (0.4,-0.15)
con = patches.ConnectionPatch(xy2,
xy1,
coordsA="axes fraction",
coordsB="axes fraction",
arrowstyle="<-",
#mutation_scale=20,
)
ax.add_artist(con)
ax.text(txt_pos[0], txt_pos[1], 'Turn number',
transform=ax.transAxes,
bbox=dict(boxstyle='round', pad=0.3,ec='w',fc='w'))
plt.show()