I'm working with some event handling in matplotlib. Specifically 'key_press_event's. But the predefined keyboard shortcuts are getting in my way. Is there a way to turn these off?
They say I can override the keys by use of: "matplotlibrc (#keymap.*)". But I don't understand what they're referring to and I haven't found any further explanation.
Select “Keyboard” from the list on the left side of your screen. Click on “Shortcuts” in the list of settings across the top of the window. Once inside “Shortcuts,” uncheck the box next to each shortcut to disable it.
In the Settings screen, in the lower-right corner, click Change PC settings. In the PC Settings screen, click Ease of Access. In the Ease of Access screen, click Keyboard. In the Keyboard screen, click the button under Sticky Keys, Filter Keys or Toggle Keys to turn each of those features either On or Off.
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.*']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With