Hello John and NG,
>> I answered this question before at
>>
>> http://sourceforge.net/mailarchive/message.php?msg_id=11115023
>>
> Probably I did not make myself clear.
>> In a nutshell, do not manually bind 'g' to toggle the grid.
>> This already happens by default in matplotlib 0.72.
> I am NOT manually binding the "g" key! I have NO
> key_press_event on my routines. Similarly, the examples:
> - embedding_in_wx.py - embedding_in_wx2.py -
> wxcursor_demo.py
OK, I see. Sorry for the confusion. The default keybindings are made
in the backend FigureManager classes. All of the examples you
referenced embed matplotlib in a wx app. The ones that use the
FigureManagerWX (eg embedding_in_wx.py) have the default key bindings;
the ones that don't use FigureManagerWX (eg embedding_in_wx2.py), do
not. If you don't use the manager, you have to do the bindings you
want yourself. Eg, in embedding_in_wx2.py
self.axes.plot(t,s)
self.canvas = FigureCanvas(self, -1, self.figure)
def toggle_grid(event):
self.axes.grid()
self.canvas.draw()
self.canvas.mpl_connect('key_press_event', toggle_grid)
Hope this helps,
JDH