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

    Click :ref:`here <sphx_glr_download_gallery_lines_bars_and_markers_step_demo.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_lines_bars_and_markers_step_demo.py:


=========
Step Demo
=========

This example demonstrates the use of `.pyplot.step` for piece-wise constant
curves. In particular, it illustrates the effect of the parameter *where*
on the step position.

The circular markers created with `.pyplot.plot` show the actual data
positions so that it's easier to see the effect of *where*.


.. code-block:: python

    import numpy as np
    import matplotlib.pyplot as plt

    x = np.arange(14)
    y = np.sin(x / 2)

    plt.step(x, y + 2, label='pre (default)')
    plt.plot(x, y + 2, 'C0o', alpha=0.5)

    plt.step(x, y + 1, where='mid', label='mid')
    plt.plot(x, y + 1, 'C1o', alpha=0.5)

    plt.step(x, y, where='post', label='post')
    plt.plot(x, y, 'C2o', alpha=0.5)

    plt.legend(title='Parameter where:')
    plt.show()




.. image:: /gallery/lines_bars_and_markers/images/sphx_glr_step_demo_001.png
    :class: sphx-glr-single-img




------------

References
""""""""""

The use of the following functions, methods, classes and modules is shown
in this example:



.. code-block:: python


    import matplotlib
    matplotlib.axes.Axes.step
    matplotlib.pyplot.step







.. _sphx_glr_download_gallery_lines_bars_and_markers_step_demo.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: step_demo.ipynb <step_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>`_
