
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/lines_bars_and_markers/vline_hline_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_vline_hline_demo.py>`
        to download the full example code.

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

.. _sphx_glr_gallery_lines_bars_and_markers_vline_hline_demo.py:


=================
hlines and vlines
=================

This example showcases the functions hlines and vlines.

.. GENERATED FROM PYTHON SOURCE LINES 8-36

.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    # Fixing random state for reproducibility
    np.random.seed(19680801)

    t = np.arange(0.0, 5.0, 0.1)
    s = np.exp(-t) + np.sin(2 * np.pi * t) + 1
    nse = np.random.normal(0.0, 0.3, t.shape) * s

    fig, (vax, hax) = plt.subplots(1, 2, figsize=(12, 6))

    vax.plot(t, s + nse, '^')
    vax.vlines(t, [0], s)
    # By using ``transform=vax.get_xaxis_transform()`` the y coordinates are scaled
    # such that 0 maps to the bottom of the Axes and 1 to the top.
    vax.vlines([1, 2], 0, 1, transform=vax.get_xaxis_transform(), colors='r')
    vax.set_xlabel('time (s)')
    vax.set_title('Vertical lines demo')

    hax.plot(s + nse, t, '^')
    hax.hlines(t, [0], s, lw=2)
    hax.set_xlabel('time (s)')
    hax.set_title('Horizontal lines demo')

    plt.show()




.. image-sg:: /gallery/lines_bars_and_markers/images/sphx_glr_vline_hline_demo_001.png
   :alt: Vertical lines demo, Horizontal lines demo
   :srcset: /gallery/lines_bars_and_markers/images/sphx_glr_vline_hline_demo_001.png, /gallery/lines_bars_and_markers/images/sphx_glr_vline_hline_demo_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 37-41

.. tags::

   plot-type: line
   level: beginner


.. _sphx_glr_download_gallery_lines_bars_and_markers_vline_hline_demo.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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