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

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

.. _sphx_glr_gallery_lines_bars_and_markers_stem_plot.py:


=========
Stem Plot
=========

Stem plot plots vertical lines from baseline to the y-coordinate
Plotting cosine(x) w.r.t x, using '-.' as the pattern
for plotting vertical lines



.. code-block:: python

    import matplotlib.pyplot as plt
    import numpy as np

    # returns 10 evenly spaced samples from 0.1 to 2*PI
    x = np.linspace(0.1, 2 * np.pi, 10)

    markerline, stemlines, baseline = plt.stem(x, np.cos(x), '-.')

    # setting property of baseline with color red and linewidth 2
    plt.setp(baseline, color='r', linewidth=2)

    plt.show()




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




This example makes use of:
* :meth:`matplotlib.axes.Axes.stem`



.. _sphx_glr_download_gallery_lines_bars_and_markers_stem_plot.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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