Search code examples
pythonmatplotlibmatplotlib-widget

How to change the text size in a matplotlib Button?


I have a button in matplotlib, i.e.

myButton = Button(axpos, 'This is a button')

How do I make the text inside the button smaller?


Solution

  • To change the font size of a matplotlib text, use text.set_fontsize(12). To get the text of the button, use myButton.label.

    Combine the two:

    myButton.label.set_fontsize(12)