
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/lines_bars_and_markers/stem_plot.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_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
=========

`~.pyplot.stem` plots vertical lines from a baseline to the y-coordinate and
places a marker at the tip.

.. GENERATED FROM PYTHON SOURCE LINES 9-18

.. code-block:: Python

    import matplotlib.pyplot as plt
    import numpy as np

    x = np.linspace(0.1, 2 * np.pi, 41)
    y = np.exp(np.sin(x))

    plt.stem(x, y)
    plt.show()




.. image-sg:: /gallery/lines_bars_and_markers/images/sphx_glr_stem_plot_001.png
   :alt: stem plot
   :srcset: /gallery/lines_bars_and_markers/images/sphx_glr_stem_plot_001.png, /gallery/lines_bars_and_markers/images/sphx_glr_stem_plot_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 19-24

The position of the baseline can be adapted using *bottom*.
The parameters *linefmt*, *markerfmt*, and *basefmt* control basic format
properties of the plot. However, in contrast to `~.pyplot.plot` not all
properties are configurable via keyword arguments. For more advanced
control adapt the line objects returned by `.pyplot`.

.. GENERATED FROM PYTHON SOURCE LINES 25-31

.. code-block:: Python


    markerline, stemlines, baseline = plt.stem(
        x, y, linefmt='grey', markerfmt='D', bottom=1.1)
    markerline.set_markerfacecolor('none')
    plt.show()




.. image-sg:: /gallery/lines_bars_and_markers/images/sphx_glr_stem_plot_002.png
   :alt: stem plot
   :srcset: /gallery/lines_bars_and_markers/images/sphx_glr_stem_plot_002.png, /gallery/lines_bars_and_markers/images/sphx_glr_stem_plot_002_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 32-43

.. admonition:: References

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

   - `matplotlib.axes.Axes.stem` / `matplotlib.pyplot.stem`

.. tags::

   plot-type: stem
   level: beginner


.. _sphx_glr_download_gallery_lines_bars_and_markers_stem_plot.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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