Python combined with Matplotlib to add button

This article reprinted from https://www.it610.com/article/1282212275846922240.htm
if you have offended, please contact me
I looked for Matplotlib button for a long time before I found something I could understand. I don’t know if it was too simple, so no one wrote it.
ttonAxe = PLT.axes ([0.94, 0.03, 0.03, 0.03]) u>to set the position of the button.
tton1 = Button(buttonAxe, 'p2',color='khaki', overcolor='yellow') i>ed to create the Button and to set the color and the color of the Button when the mouse is over the Button.
third line tton1.on_clicked (show2) s>the function triggered after the button is clicked.
in addition to write after click the button to trigger functions should pay attention to write the event in the brackets, such as def show2 (event) :

buttonaxe = plt.axes([0.94, 0.03, 0.03, 0.03])
button1 = Button(buttonaxe, 'p2',color='khaki', hovercolor='yellow')
button1.on_clicked(show2)


Read More: