I have the following code example. When I press the button the color changes. However only after I move the mouse a little. Can I somehow directly call the draw function?
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
def toggle(_):
button.status ^= True
color = [0, 1, 0] if button.status else [1, 0, 0]
button.color = color
button.hovercolor = color
# Stuff that doesn't work...
plt.draw()
button.canvas.draw()
plt.gcf().canvas.draw()
button = Button(plt.axes([.1, .1, .8, .8]), 'Press me')
button.status = True
button.on_clicked(toggle)
plt.show()