Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from matplotlib import pyplot as plt
- fig, ax = plt.subplots()
- x=1
- def annotate():
- global x
- if x==1:
- x=-1
- else:
- x=1
- ax.annotate(x, (0.5,0.5), textcoords='data', size=10)
- ax.annotate('Other annotation', (0.5,0.4), textcoords='data', size=10)
- def onclick(event):
- annotate()
- fig.canvas.draw()
- cid = fig.canvas.mpl_connect('button_press_event',onclick)
- from matplotlib import pyplot as plt
- fig, ax = plt.subplots()
- x=1
- annotation = ax.annotate('', (0.5,0.5), textcoords='data', size=10) # empty annotate object
- other_annotation = ax.annotate('Other annotation', (0.5,0.4), textcoords='data', size=10) # other annotate
- def annotate():
- global x
- if x==1:
- x=-1
- else:
- x=1
- annotation.set_text(x)
- def onclick(event):
- annotate()
- fig.canvas.draw()
- cid = fig.canvas.mpl_connect('button_press_event',onclick)
- plt.show()
Add Comment
Please, Sign In to add comment