Document default key-bindings

matplotlib 1.4.2
TkAgg 8.5
python 2.7.3
OSX 10.8.5

After plotting a figure and using the interactive features, pressing certain number keys (2-9) disables the display of the x, y coordinates on the interactive navigation menu. Pressing ‘1’ restores this functionality. This prevents the number keys from being used in key mappings and having the coordinates interactively updated.

Reproduce with:

import matplotlib.pyplot as plt

  • move the cursor to cause the x,y coordinates to display
  • press a number key and move the cursor (‘2’-‘9’ turn off, ‘1’ restores the coordinate display)

Author: Fantashit

1 thought on “Document default key-bindings

  1. Ah hah! I knew I came across something about this when researching my book.
    In for key_press_handler():

        elif (event.key.isdigit() and event.key != '0') or event.key in all:
            # keys in list 'all' enables all axes (default key 'a'),
            # otherwise if key is a number only enable this particular axes
            # if it was the axes, where the event was raised
            if not (event.key in all):
                n = int(event.key) - 1
            for i, a in enumerate(canvas.figure.get_axes()):
                # consider axes, in which the event was raised
                # FIXME: Why only this axes?
                if event.x is not None and event.y is not None \
                        and a.in_axes(event):
                    if event.key in all:
                        a.set_navigate(i == n)

    Essentially, it sets which axes are “navigable”. I have zero clue if this
    is actually documented anywhere, though.

    The way to disable the default keymap in matplotlib is:

                manager, canvas = figure.canvas.manager, figure.canvas

    On Tue, Jan 20, 2015 at 4:37 PM, kogelnik wrote:

    I haven’t found any documentation on this. matplotlibrc and plt.rcParams
    don’t show any obvious mappings. (‘a’ can also be used set all axes.)

    Is there a way to disable/override this feature?

    Reply to this email directly or view it on GitHub
    #4020 (comment)

Comments are closed.