.. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` 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. .. code-block:: default 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:: /gallery/lines_bars_and_markers/images/sphx_glr_stem_plot_001.png :alt: stem plot :class: sphx-glr-single-img 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`. .. code-block:: default markerline, stemlines, baseline = plt.stem( x, y, linefmt='grey', markerfmt='D', bottom=1.1) markerline.set_markerfacecolor('none') plt.show() .. image:: /gallery/lines_bars_and_markers/images/sphx_glr_stem_plot_002.png :alt: stem plot :class: sphx-glr-single-img ------------ References """""""""" The use of the following functions, methods, classes and modules is shown in this example: .. code-block:: default import matplotlib matplotlib.pyplot.stem matplotlib.axes.Axes.stem .. rst-class:: sphx-glr-script-out Out: .. code-block:: none .. _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 sphx-glr-download-python :download:`Download Python source code: stem_plot.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: stem_plot.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature Keywords: matplotlib code example, codex, python plot, pyplot `Gallery generated by Sphinx-Gallery `_