1ax = plt.axes(projection='3d')
2
3# Data for a three-dimensional line
4zline = np.linspace(0, 15, 1000)
5xline = np.sin(zline)
6yline = np.cos(zline)
7ax.plot3D(xline, yline, zline, 'gray')
8
9# Data for three-dimensional scattered points
10zdata = 15 * np.random.random(100)
11xdata = np.sin(zdata) + 0.1 * np.random.randn(100)
12ydata = np.cos(zdata) + 0.1 * np.random.randn(100)
13ax.scatter3D(xdata, ydata, zdata, c=zdata, cmap='Greens');
14
1def f(x, y):
2 return np.sin(np.sqrt(x ** 2 + y ** 2))
3
4x = np.linspace(-6, 6, 30)
5y = np.linspace(-6, 6, 30)
6
7X, Y = np.meshgrid(x, y)
8Z = f(X, Y)
9