The mplot3d toolkit#

Generating 3D plots using the mplot3d toolkit.

This tutorial showcases various 3D plots. Click on the figures to see each fullgallery example with the code that generates the figures.

3D Axes (of classAxes3D) are created by passing theprojection="3d"keyword argument toFigure.add_subplot:

importmatplotlib.pyplotaspltfig=plt.figure()ax=fig.add_subplot(projection='3d')

Multiple 3D subplots can be added on the same figure, as for 2D subplots.

../../../_images/sphx_glr_subplot3d_001.png

Changed in version 3.2.0:Prior to Matplotlib 3.2.0, it was necessary to explicitly import thempl_toolkits.mplot3d module to make the '3d' projection toFigure.add_subplot.

See themplot3d FAQ for more information about the mplot3dtoolkit.

Line plots#

SeeAxes3D.plot for API documentation.

../../../_images/sphx_glr_lines3d_001.png

Scatter plots#

SeeAxes3D.scatter for API documentation.

../../../_images/sphx_glr_scatter3d_001.png

Wireframe plots#

SeeAxes3D.plot_wireframe for API documentation.

../../../_images/sphx_glr_wire3d_001.png

Surface plots#

SeeAxes3D.plot_surface for API documentation.

../../../_images/sphx_glr_surface3d_001.png

Tri-Surface plots#

SeeAxes3D.plot_trisurf for API documentation.

../../../_images/sphx_glr_trisurf3d_001.png

Contour plots#

SeeAxes3D.contour for API documentation.

../../../_images/sphx_glr_contour3d_001.png

Filled contour plots#

SeeAxes3D.contourf for API documentation.

../../../_images/sphx_glr_contourf3d_001.png

Added in version 1.1.0:The feature demoed in the second contourf3d example was enabled as aresult of a bugfix for version 1.1.0.

Fill between 3D lines#

SeeAxes3D.fill_between for API documentation.

../../../_images/sphx_glr_fillbetween3d_001.png

Added in version 3.10.

Polygon plots#

SeeAxes3D.add_collection3d for API documentation.

../../../_images/sphx_glr_polys3d_001.png

Bar plots#

SeeAxes3D.bar for API documentation.

../../../_images/sphx_glr_bars3d_001.png

Quiver#

SeeAxes3D.quiver for API documentation.

../../../_images/sphx_glr_quiver3d_001.png

2D plots in 3D#

../../../_images/sphx_glr_2dcollections3d_001.png

Text#

SeeAxes3D.text for API documentation.

../../../_images/sphx_glr_text3d_001.png