How do I disable the keyboard shortcuts in Matplotlib?

You can modify in plt.rcParams dictionary. Example, to disable the "s" keyboard shortcut for the "save figure" button:

>>> plt.rcParams['keymap.save']
['s', 'ctrl+s']
>>> plt.rcParams['keymap.save'].remove('s')

If you want the changes to apply globally/permanently, then edit in the matplotlibrc file and restart the Python interpreter. You may find the location of the config file on your system by calling a helper function:

>>> matplotlib.matplotlib_fname()
'/Users/wim/.matplotlib/matplotlibrc'

Note: In older versions of matplotlib, the keymap bindings were strings rather than lists. If you are stuck on older version, you could set the value to an empty string rather than calling remove.


See https://matplotlib.org/users/customizing.html for all keymap keywords that you can use with the above mentioned method, plt.rcParams['keymap.*']