Matplotlib 3D Scatter plot - How to make scatter plots in 3D

we can draw 3D scatter plots with pyplot module in Python Matplotlib. Before plotting, create a new figure by figure method.

from matplotlib import pyplot

fig = pyplot.figure()
ax = fig.add_subplot(111, projection='3d')

x = [1, 2, 3]
y = [4, 5, 6]
z = [7, 8, 9]

ax.scatter(x, y, z)

pyplot.savefig('plot.png')

Matplotlib Scatter

Matplotlib Tutorial