import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from mpl_toolkits.mplot3d import Axes3D
3D
fig = plt.figure()
ax = Axes3D(fig)
x = np.arange(-4,4,0.25)
y = np.arange(-4,4,0.25)
X,Y = np.meshgrid(x,y)
Z = np.sin(np.sqrt(X**2+Y**2))
ax.plot_surface(x,y,Z, rstride=1, cstride=1, cmap='rainbow')
<mpl_toolkits.mplot3d.art3d.Poly3DCollection at 0x1b1c214d208>
![请添加图片描述](https://i-blog.csdnimg.cn/blog_migrate/6d23de52b953eb08890b8186fd41a07d.png)
fig = plt.figure()
ax = fig.add_subplot(211, projection='3d')
x = np.arange(-4,4,0.25)
y = np.arange(-4,4,0.25)
z = np.sin(np.sqrt(x**2+y**2))
ax.plot(x,y,z)
[<mpl_toolkits.mplot3d.art3d.Line3D at 0x1b1c1f1c0f0>]
![请添加图片描述](https://i-blog.csdnimg.cn/blog_migrate/20adab29bc31ff25b781b2e6e1d7f5c2.png)
fig = plt.figure()
ax = fig.add_subplot(211, projection='3d')
x = np.arange(-4,4,0.25)
y = np.arange(-4,4,0.25)
z = np.sin(np.sqrt(x**2+y**2))
ax.scatter(x,y,z)
<mpl_toolkits.mplot3d.art3d.Path3DCollection at 0x1b1c36276d8>
![请添加图片描述](https://i-blog.csdnimg.cn/blog_migrate/7b0d8c8a6763c581b4e65169385494e0.png)
fig = plt.figure(figsize=(8,10))
ax = fig.add_subplot(211, projection='3d')
ax.set_zlim([0,4])
for i in range(3):
x = np.arange(0,4,0.25)
y = np.arange(0,4,0.25)
ax.bar(x,y,zs=i*10, zdir='y', alpha=0.5)
![请添加图片描述](https://i-blog.csdnimg.cn/blog_migrate/5b5b9ac9b867e12b3f2cc0327c881680.png)