

.. _sphx_glr_examples_highlight.py:


Highlighting the artist upon selection
======================================

Just pass ``highlight=True`` to `cursor`.




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





.. code-block:: python


    import numpy as np
    import matplotlib.pyplot as plt
    import mplcursors

    x = np.linspace(0, 10, 100)

    fig, ax = plt.subplots()

    # Plot a series of lines with increasing slopes...
    lines = []
    for i in range(1, 20):
        line, = ax.plot(x, i * x, label="$y = {}x$".format(i))
        lines.append(line)

    mplcursors.cursor(lines, highlight=True)

    plt.show()



.. only :: html

 .. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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


.. only:: html

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

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