# Line colour of a 3D parametric curve in Python's Matplotlib.pyplot

MatplotlibPythonData Visualization

#### Python Data Science basics with Numpy, Pandas and Matplotlib

Most Popular

63 Lectures 6 hours

#### Data Visualization using MatPlotLib & Seaborn

11 Lectures 4 hours

#### MatPlotLib with Python

9 Lectures 2.5 hours

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()
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()

## Output

Updated on 03-Jun-2021 12:51:08