Import Python modules
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
Create a 3D canvas
fig = plt.figure()
ax = plt.axes(projection='3d')
Create a 3D spiral line
ax = plt.axes(projection='3d')
zline = np.linspace(0,15,1000)
xline = np.sin(zline)
yline = np.cos(zline)
ax.plot3D(xline, yline, zline)
[<mpl_toolkits.mplot3d.art3d.Line3D at 0x26088ece590>]
Create 3D dots
ax = plt.axes(projection='3d')
zdata = 10 * np.random.random(50)
xdata = np.sin(zdata)
ydata = np.cos(zdata)
ax.scatter3D(xdata, ydata, zdata, c=zdata, cmap='Greens')
<mpl_toolkits.mplot3d.art3d.Path3DCollection at 0x2608be04bd0>