
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/mplot3d/stem3d_demo.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

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

        Click :ref:`here <sphx_glr_download_gallery_mplot3d_stem3d_demo.py>`
        to download the full example code

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

.. _sphx_glr_gallery_mplot3d_stem3d_demo.py:


=======
3D stem
=======

Demonstration of a stem plot in 3D, which plots vertical lines from a baseline
to the *z*-coordinate and places a marker at the tip.

.. GENERATED FROM PYTHON SOURCE LINES 9-23

.. code-block:: default


    import matplotlib.pyplot as plt
    import numpy as np

    theta = np.linspace(0, 2*np.pi)
    x = np.cos(theta - np.pi/2)
    y = np.sin(theta - np.pi/2)
    z = theta

    fig, ax = plt.subplots(subplot_kw=dict(projection='3d'))
    ax.stem(x, y, z)

    plt.show()




.. image-sg:: /gallery/mplot3d/images/sphx_glr_stem3d_demo_001.png
   :alt: stem3d demo
   :srcset: /gallery/mplot3d/images/sphx_glr_stem3d_demo_001.png, /gallery/mplot3d/images/sphx_glr_stem3d_demo_001_2_0x.png 2.0x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 24-29

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 `~.axes3d.Axes3D.plot` not all properties are
configurable via keyword arguments. For more advanced control adapt the line
objects returned by `.stem3D`.

.. GENERATED FROM PYTHON SOURCE LINES 30-38

.. code-block:: default


    fig, ax = plt.subplots(subplot_kw=dict(projection='3d'))
    markerline, stemlines, baseline = ax.stem(
        x, y, z, linefmt='grey', markerfmt='D', bottom=np.pi)
    markerline.set_markerfacecolor('none')

    plt.show()




.. image-sg:: /gallery/mplot3d/images/sphx_glr_stem3d_demo_002.png
   :alt: stem3d demo
   :srcset: /gallery/mplot3d/images/sphx_glr_stem3d_demo_002.png, /gallery/mplot3d/images/sphx_glr_stem3d_demo_002_2_0x.png 2.0x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 39-45

The orientation of the stems and baseline can be changed using *orientation*.
This determines in which direction the stems are projected from the head
points, towards the *bottom* baseline.

For examples, by setting ``orientation='x'``, the stems are projected along
the *x*-direction, and the baseline is in the *yz*-plane.

.. GENERATED FROM PYTHON SOURCE LINES 46-52

.. code-block:: default


    fig, ax = plt.subplots(subplot_kw=dict(projection='3d'))
    markerline, stemlines, baseline = ax.stem(x, y, z, bottom=-1, orientation='x')
    ax.set(xlabel='x', ylabel='y', zlabel='z')

    plt.show()



.. image-sg:: /gallery/mplot3d/images/sphx_glr_stem3d_demo_003.png
   :alt: stem3d demo
   :srcset: /gallery/mplot3d/images/sphx_glr_stem3d_demo_003.png, /gallery/mplot3d/images/sphx_glr_stem3d_demo_003_2_0x.png 2.0x
   :class: sphx-glr-single-img






.. _sphx_glr_download_gallery_mplot3d_stem3d_demo.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: stem3d_demo.py <stem3d_demo.py>`



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

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