import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.gca(projection='3d')# sin curve on X-Y plane
x = np.linspace(0,1,100)
y = np.sin(x*2*np.pi)/2+0.5
ax.plot(x, y, zs=0, zdir='z', label='sin curve')
colors =('r','g','b','k')# all colors
np.random.seed(10)
x = np.random.sample(20*len(colors))
y = np.random.sample(20*len(colors))
c_lst =[]for c in colors:
c_lst.extend([c]*20)
ax.scatter(x, y, zs=0, zdir='y', c=c_lst, label='points in (x, z)')
ax.legend()
ax.set_xlim(0,1)
ax.set_ylim(0,1)
ax.set_zlim(0,1)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.view_init(elev=20, azim=-35)
plt.show()