

.. _sphx_glr_examples_keyboard_shortcuts.py:


Keyboard shortcuts
==================

By default, mplcursors uses "t" to toggle interactivity and "d" to hide/show
annotation boxes.  These shortcuts can be customized.




.. image:: /examples/images/sphx_glr_keyboard_shortcuts_001.png
    :align: center





.. code-block:: python


    import matplotlib.pyplot as plt
    import mplcursors

    fig, ax = plt.subplots()
    ax.plot(range(10), "o-")
    ax.set_title('Press "e" to enable/disable the datacursor\n'
                 'Press "h" to hide/show any annotation boxes')

    mplcursors.cursor(bindings={"toggle_visible": "h", "toggle_enabled": "e"})

    plt.show()



.. only :: html

 .. container:: sphx-glr-footer


  .. container:: sphx-glr-download

     :download:`Download Python source code: keyboard_shortcuts.py <keyboard_shortcuts.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: keyboard_shortcuts.ipynb <keyboard_shortcuts.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
