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.
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.
所有评论(0)