- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to plot 3D graphs using Python Matplotlib?
To plot 3D graphs using Python, we can take the following steps −
Create a new figure or activate an existing figure using figure() method.
Get the 3D axes object.
Make x, y, and z lists for data points.
Add 3D scatter points using scatter3D() method, with x, y, and z data points with markersize=150 and marker=diamond.
To display the figure, use show() method.
Example
from mpl_toolkits.mplot3d import Axes3D from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = Axes3D(fig) x = [2, 4, 6, 3, 1] y = [1, 6, 8, 1, 3] z = [3, 4, 10, 3, 1] ax.scatter3D(x, y, z, c=z, alpha=1, marker='d', s=150) plt.show()
Output
- Related Articles
- How to plot multiple graphs in Matplotlib?
- How to plot a 3D density map in Python with Matplotlib?
- How to surface plot/3D plot from a dataframe (Matplotlib)?
- How to plot a 3D patch collection in matplotlib?
- How to plot a 3D continuous line in Matplotlib?
- Make 3D plot interactive in Jupyter Notebook (Python & Matplotlib)
- Controlling the alpha value on a 3D scatter plot using Python and Matplotlib
- Plot Matplotlib 3D plot_surface with contour plot projection
- How to plot a point on 3D axes in Matplotlib?
- How to plot MFCC in Python using Matplotlib?
- How to plot vectors in Python using Matplotlib?
- How do I plot two countplot graphs side by side in Seaborn using Matplotlib?
- Plot 3D bars without axes in Matplotlib
- Creating a 3D plot in Matplotlib from a 3D numpy array
- How to display a 3D plot of a 3D array isosurface in matplotlib mplot3D or similar?

Advertisements