

.. _sphx_glr_gallery_mplot3d_lines3d.py:


================
Parametric Curve
================

This example demonstrates plotting a parametric curve in 3D.




.. image:: /gallery/mplot3d/images/sphx_glr_lines3d_001.png
    :align: center





.. code-block:: python


    import matplotlib as mpl
    from mpl_toolkits.mplot3d import Axes3D
    import numpy as np
    import matplotlib.pyplot as plt

    mpl.rcParams['legend.fontsize'] = 10

    fig = plt.figure()
    ax = fig.gca(projection='3d')

    # Prepare arrays x, y, z
    theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
    z = np.linspace(-2, 2, 100)
    r = z**2 + 1
    x = r * np.sin(theta)
    y = r * np.cos(theta)

    ax.plot(x, y, z, label='parametric curve')
    ax.legend()

    plt.show()

**Total running time of the script:** ( 0 minutes  0.033 seconds)



.. only :: html

 .. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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


.. only:: html

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

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