- 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 a 3D continuous line in Matplotlib?
To plot a 3D continuous line in Matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create x and y data points using numpy.
Create z data points using x and y data points.
Create a new figure or activate an existing figure using figure() method.
Add an axes as a subplot arrangement with 3D projection.
Plot x, y and z data points using plot() method.
To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-4 * np.pi, 4 * np.pi, 50) y = np.linspace(-4 * np.pi, 4 * np.pi, 50) z = x ** 2 + y ** 2 fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot(x, y, z) plt.show()
Output
- Related Articles
- How to surface plot/3D plot from a dataframe (Matplotlib)?
- How to plot a 3D patch collection in matplotlib?
- How to plot a point on 3D axes in Matplotlib?
- How to plot 3D graphs using Python Matplotlib?
- Creating a 3D plot in Matplotlib from a 3D numpy array
- How to plot a 3D density map in Python with Matplotlib?
- How to animate a line plot in Matplotlib?
- How to display a 3D plot of a 3D array isosurface in matplotlib mplot3D or similar?
- How to plot a gradient color line in matplotlib?
- How to plot a smooth line with matplotlib?
- Plot Matplotlib 3D plot_surface with contour plot projection
- Plot 3D bars without axes in Matplotlib
- How to plot scatter points in a 3D figure with a colorbar in Matplotlib?
- How can I make a simple 3D line with Matplotlib?
- How to turn off transparency in Matplotlib's 3D Scatter plot?

Advertisements