- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 can I make a simple 3D line with Matplotlib?
To make a simple 3D line with matplotlib, we can take the following steps −
Create a new figure or activate an existing figure.
Add axes to the figure as part of a subplot arrangement.
Create data points for theta, z, r, x and y using numpy.
Plot x, y and z using plot() method.
Place a legend on the figure using legend() method.
To display the figure, use show() method.
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.add_subplot(projection='3d') 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()
- How can I make the xtick labels of a plot be simple drawings using Matplotlib?
- How can I create a stacked line graph with matplotlib?
- How can I hide the axes in Matplotlib 3D?
- How can I render 3D histograms in Python using Matplotlib?
- How to plot a 3D continuous line in Matplotlib?
- How can I make simple and quick poha at home?
- How to make a simple lollipop plot in Matplotlib?
- How can I draw a scatter trend line using Matplotlib?
- How can I cycle through line styles in Matplotlib?
- How can I draw inline line labels in Matplotlib?
- How can I make a scatter plot colored by density in Matplotlib?
- How can I make money with Python?
- Make 3D plot interactive in Jupyter Notebook (Python & Matplotlib)
- Can I give a border to a line in Matplotlib plot function?
- How Can I Make Money with Blockchain Technology?