
.. 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

    .. meta::
        :keywords: codex

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

        :ref:`Go to the end <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-34

.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    from matplotlib import patheffects

    # Plot a straight diagonal line with ticked style path
    fig, ax = plt.subplots(figsize=(6, 6))
    ax.plot([0, 1], [0, 1], label="Line",
            path_effects=[patheffects.withTickedStroke(spacing=7, angle=135)])

    # Plot a curved line with ticked style path
    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()




.. 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_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 35-40

.. tags::

   styling: linestyle
   plot-type: line
   level: beginner


.. _sphx_glr_download_gallery_lines_bars_and_markers_lines_with_ticks_demo.py:

.. only:: html

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

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

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

    .. 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-zip

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


.. only:: html

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

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