.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/plot_line_end_labels.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_plot_line_end_labels.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_plot_line_end_labels.py:


==============================================================================
Line end labelling
==============================================================================
An example demonstrating the use of label_line_ends to
automatically label the ends of lines nicely.

.. GENERATED FROM PYTHON SOURCE LINES 8-44



.. image-sg:: /auto_examples/images/sphx_glr_plot_line_end_labels_001.svg
   :alt: plot line end labels
   :srcset: /auto_examples/images/sphx_glr_plot_line_end_labels_001.svg
   :class: sphx-glr-single-img





.. code-block:: Python


    # ==============================================================================
    # External Python modules
    # ==============================================================================
    import numpy as np
    import matplotlib.pyplot as plt
    import niceplots


    def plot_colored_lines(ax, n_lines=3):
        """Plot lines with colors following the style color cycle.

        Adapted from https://matplotlib.org/stable/gallery/style_sheets/style_sheets_reference.html
        """
        t = np.linspace(-10, 20, 100)

        def sigmoid(t, t0):
            return 1 / (1 + np.exp(-(t - t0)))

        shifts = np.linspace(0, 10, n_lines)
        amplitudes = np.linspace(1, 1.5, n_lines)
        for t0, a in zip(shifts, amplitudes):
            ax.plot(t, a * sigmoid(t, t0), "-", label=f"$t_0={t0}$", clip_on=False)
        ax.set_xlim(-10, 20)


    plt.style.use(niceplots.get_style())

    fig, ax = plt.subplots()
    plot_colored_lines(ax)
    ax.set_xlabel("t")
    ax.set_ylabel("$\sigma$", rotation="horizontal", ha="right")
    niceplots.adjust_spines(ax)
    niceplots.label_line_ends(ax)

    niceplots.save_figs(fig, "line_end_labels", ["png", "svg"], format_kwargs={"png": {"dpi": 400}}, bbox_inches="tight")


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 1.009 seconds)


.. _sphx_glr_download_auto_examples_plot_line_end_labels.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

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

    .. container:: sphx-glr-download sphx-glr-download-python

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

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_line_end_labels.zip <plot_line_end_labels.zip>`


.. only:: html

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

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