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

.. only:: html

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

        Click :ref:`here <sphx_glr_download_gallery_lines_bars_and_markers_lines_with_ticks_demo.py>`
        to download the full example code

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

.. _sphx_glr_gallery_lines_bars_and_markers_lines_with_ticks_demo.py:


==============================
Lines with a ticked patheffect
==============================

Ticks can be added along a line to mark one side as a barrier using
`~matplotlib.patheffects.TickedStroke`.  You can control the angle,
spacing, and length of the ticks.

The ticks will also appear appropriately in the legend.

.. GENERATED FROM PYTHON SOURCE LINES 13-30



.. image-sg:: /gallery/lines_bars_and_markers/images/sphx_glr_lines_with_ticks_demo_001.png
   :alt: lines with ticks demo
   :srcset: /gallery/lines_bars_and_markers/images/sphx_glr_lines_with_ticks_demo_001.png, /gallery/lines_bars_and_markers/images/sphx_glr_lines_with_ticks_demo_001_2_0x.png 2.0x
   :class: sphx-glr-single-img





.. code-block:: default


    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import patheffects

    fig, ax = plt.subplots(figsize=(6, 6))
    ax.plot([0, 1], [0, 1], label="Line",
            path_effects=[patheffects.withTickedStroke(spacing=7, angle=135)])

    nx = 101
    x = np.linspace(0.0, 1.0, nx)
    y = 0.3*np.sin(x*8) + 0.4
    ax.plot(x, y, label="Curve", path_effects=[patheffects.withTickedStroke()])

    ax.legend()

    plt.show()


.. _sphx_glr_download_gallery_lines_bars_and_markers_lines_with_ticks_demo.py:


.. only :: html

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



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

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



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

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


.. only:: html

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

    Keywords: matplotlib code example, codex, python plot, pyplot
    `Gallery generated by Sphinx-Gallery
    <https://sphinx-gallery.readthedocs.io>`_
