

.. _sphx_glr_gallery_mplot3d:

.. _mplot3d_example:

.. _mplot3d-examples-index:

3D plotting
===========



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates using ax.plot&#x27;s zdir keyword to plot 2D data on selective axes of a 3D plot.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_2dcollections3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_2dcollections3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Plot 2D data on 3D plot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A basic demo of how to plot 3D bars with and without shading.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_3d_bars_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_3d_bars.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Demo of 3D bar charts</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates making a 3D plot which has 2D bar graphs projected onto planes y=0, y=1, etc.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_bars3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_bars3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Create 2D bar graphs in different planes</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Given data on a gridded volume X, Y, Z, this example plots the data values on the volume surfac...">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_box3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_box3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D box surface plot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This is like a contour plot in 2D except that the f(x, y)=c curve is plotted on the plane z=c.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_contour3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_contour3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Plot contour (level) curves in 3D</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This modification of the contour3d example uses extend3d=True to extend the curves vertically i...">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_contour3d_2_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_contour3d_2.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Plot contour (level) curves in 3D using the extend3d option</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Project contour profiles onto a graph">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_contour3d_3_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_contour3d_3.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Project contour profiles onto a graph</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip=".Axes3D.contourf differs from .Axes3D.contour in that it creates filled contours, i.e. a discre...">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_contourf3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_contourf3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Filled contours</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Project filled contour onto a graph">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_contourf3d_2_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_contourf3d_2.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Project filled contour onto a graph</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates using custom hillshading in a 3D surface plot.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_custom_shaded_3d_surface_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_custom_shaded_3d_surface.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom hillshading in a 3D surface plot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="An example of using errorbars with upper and lower limits in mplot3d.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_errorbar3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_errorbar3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D errorbars</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demo of a histogram for 2D data as a bar graph in 3D.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_hist3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_hist3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Create 3D histogram of 2D data</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates plotting a parametric curve in 3D.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_lines3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_lines3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Parametric curve</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This is an example of plotting Edward Lorenz&#x27;s 1963 `&quot;Deterministic Nonperiodic Flow&quot;`_ in a 3-...">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_lorenz_attractor_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_lorenz_attractor.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Lorenz attractor</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example shows a how to plot a 2D and a 3D plot on the same figure.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_mixed_subplots_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_mixed_subplots.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">2D and 3D axes in same figure</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates mplot3d&#x27;s offset text display. As one rotates the 3D figure, the offs...">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_offset_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_offset.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Automatic text offsetting</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrate using .pathpatch_2d_to_3d to &#x27;draw&#x27; shapes and text on a 3D plot.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_pathpatch3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_pathpatch3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Draw flat objects in 3D plot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrate how to create polygons which fill the space under a line graph. In this example pol...">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_polys3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_polys3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Generate polygons to fill under 3D line graph</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates the different camera projections for 3D plots, and the effects of changing the foc...">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_projections_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_projections.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D plot projection types</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates plotting directional arrows at points on a 3D meshgrid.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_quiver3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_quiver3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D quiver plot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A very simple animation of a rotating 3D plot about all three axes.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_rotate_axes3d_sgskip_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_rotate_axes3d_sgskip.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Rotating a 3D plot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstration of a basic scatterplot in 3D.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_scatter3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_scatter3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D scatterplot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstration of a stem plot in 3D, which plots vertical lines from a baseline to the z-coordin...">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_stem3d_demo_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_stem3d_demo.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D stem</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrate including 3D plots as subplots.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_subplot3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_subplot3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D plots as subplots</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates plotting a 3D surface colored with the coolwarm colormap. The surface is made opaq...">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_surface3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_surface3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D surface (colormap)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates a very basic plot of a 3D surface using a solid color.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_surface3d_2_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_surface3d_2.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D surface (solid color)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates plotting a 3D surface colored in a checkerboard pattern.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_surface3d_3_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_surface3d_3.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D surface (checkerboard)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates plotting a surface defined in polar coordinates. Uses the reversed version of the ...">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_surface3d_radial_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_surface3d_radial.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D surface with polar coordinates</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates the placement of text annotations on a 3D plot.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_text3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_text3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Text annotations in 3D</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Contour plots of unstructured triangular grids.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_tricontour3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_tricontour3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Triangular 3D contour plot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Filled contour plots of unstructured triangular grids.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_tricontourf3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_tricontourf3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Triangular 3D filled contour plot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Plot a 3D surface with a triangular mesh.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_trisurf3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_trisurf3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Triangular 3D surfaces</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Two additional examples of plotting surfaces with triangular mesh.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_trisurf3d_2_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_trisurf3d_2.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">More triangular 3D surfaces</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example generates an &quot;unfolded&quot; 3D plot that shows each of the primary 3D view planes. The...">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_view_planes_3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_view_planes_3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Primary 3D view planes</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates plotting 3D volumetric objects with .Axes3D.voxels.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_voxels_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_voxels.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D voxel / volumetric plot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates using .Axes3D.voxels with uneven coordinates.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_voxels_numpy_logo_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_voxels_numpy_logo.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D voxel plot of the NumPy logo</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates using .Axes3D.voxels to visualize parts of a color space.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_voxels_rgb_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_voxels_rgb.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D voxel / volumetric plot with RGB colors</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates using the x, y, z parameters of .Axes3D.voxels.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_voxels_torus_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_voxels_torus.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D voxel / volumetric plot with cylindrical coordinates</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A very basic demonstration of a wireframe plot.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_wire3d_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_wire3d.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D wireframe plot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A very simple &quot;animation&quot; of a 3D plot.  See also rotate_axes3d_sgskip.">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_wire3d_animation_sgskip_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_wire3d_animation_sgskip.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Animate a 3D wireframe plot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Demonstrates that setting rstride or cstride to 0 causes wires to not be generated in the corre...">

.. only:: html

  .. image:: /gallery/mplot3d/images/thumb/sphx_glr_wire3d_zero_stride_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_mplot3d_wire3d_zero_stride.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3D wireframe plots in one direction</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /gallery/mplot3d/2dcollections3d
   /gallery/mplot3d/3d_bars
   /gallery/mplot3d/bars3d
   /gallery/mplot3d/box3d
   /gallery/mplot3d/contour3d
   /gallery/mplot3d/contour3d_2
   /gallery/mplot3d/contour3d_3
   /gallery/mplot3d/contourf3d
   /gallery/mplot3d/contourf3d_2
   /gallery/mplot3d/custom_shaded_3d_surface
   /gallery/mplot3d/errorbar3d
   /gallery/mplot3d/hist3d
   /gallery/mplot3d/lines3d
   /gallery/mplot3d/lorenz_attractor
   /gallery/mplot3d/mixed_subplots
   /gallery/mplot3d/offset
   /gallery/mplot3d/pathpatch3d
   /gallery/mplot3d/polys3d
   /gallery/mplot3d/projections
   /gallery/mplot3d/quiver3d
   /gallery/mplot3d/rotate_axes3d_sgskip
   /gallery/mplot3d/scatter3d
   /gallery/mplot3d/stem3d_demo
   /gallery/mplot3d/subplot3d
   /gallery/mplot3d/surface3d
   /gallery/mplot3d/surface3d_2
   /gallery/mplot3d/surface3d_3
   /gallery/mplot3d/surface3d_radial
   /gallery/mplot3d/text3d
   /gallery/mplot3d/tricontour3d
   /gallery/mplot3d/tricontourf3d
   /gallery/mplot3d/trisurf3d
   /gallery/mplot3d/trisurf3d_2
   /gallery/mplot3d/view_planes_3d
   /gallery/mplot3d/voxels
   /gallery/mplot3d/voxels_numpy_logo
   /gallery/mplot3d/voxels_rgb
   /gallery/mplot3d/voxels_torus
   /gallery/mplot3d/wire3d
   /gallery/mplot3d/wire3d_animation_sgskip
   /gallery/mplot3d/wire3d_zero_stride

