I'm running an animation using matplotlib's FuncAnimation
to display data (live) from a microprocessor. I'm using buttons to send commands to the processor and would like the color of the button to change after being clicked, but I can't find anything in the matplotlib.widgets.button
documentation (yet) that achieves this.
class Command:
def motor(self, event):
SERIAL['Serial'].write(' ')
plt.draw()
write = Command()
bmotor = Button(axmotor, 'Motor', color = '0.85', hovercolor = 'g')
bmotor.on_clicked(write.motor) #Change Button Color Here
In current matplotlib version (1.4.2) 'color' and 'hovercolor' are took into account only when mouse '_motion' event has happened, so the button change color not when you press mouse button, but only when you move mouse afterwards.
Nevertheless, you can change button background manually:
Just set
button.color
.E.g.