Bonjour, j'ai un graphique sous matploltib avec plusieur axes, le probleme c'est que j'aimerais rajouter des annotations par rapport a l'emplacement de la souris, comment définir l'axe 0 comme l'axe par défauts ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from matplotlib import pyplot as plt from matplotlib.dates import date2num fig = plt.figure() ax = fig.add_subplot(111) x=[0,1,2,3,4,5,6,7,8,9] y=[0,1,2,3,4,5,6,7,8,9] ax.plot(x,y) ax.twinx() def addnotes(event): ticks=ax.annotate("test", xy=(event.xdata, event.ydata), xycoords='data', xytext=(-50, 30), textcoords='offset points', arrowprops=dict(arrowstyle="->")) plt.show() cid = fig.canvas.mpl_connect('key_press_event', addnotes) plt.show()
Dans mon code event.ydata se position par rapport au 2eme axe y, pas au premier !
Peut on modifier ce comportement ? merci pour vos réponses.
Partager