To plot the line color of a 3D parametric curve in Matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create a new figure or activate an existing figure using figure() method.
Add an axis as a subplot arrangement.
To make a parametric curve, initialize theta, z, r, x and y variables.
Plot x, y and z data points using scatter() method.
Set the title of the plot.
To display the figure, use show() method.
Example
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 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.scatter(x, y, z, c=x, cmap="copper") ax.set_title("Parametric Curve") plt.show()