目录
3D立体图形
3D绘图
3D散点图
3D曲线图
3D平面图
3D立体图形
绘制三维图像主要通过 mplot3d 模块实现。
from matplotlib import pyplot as plt from mpl_toolkits.mplot3d import Axes3D %matplotlib notebook
3D绘图
3D绘图与2D绘图使用的方法基本一致,不同的是,操作的对象变为了 Axes3D() 对象。

目录
3D立体图形
3D绘图
3D散点图
3D曲线图
3D平面图
绘制三维图像主要通过 mplot3d 模块实现。
from matplotlib import pyplot as plt from mpl_toolkits.mplot3d import Axes3D %matplotlib notebook
3D绘图与2D绘图使用的方法基本一致,不同的是,操作的对象变为了 Axes3D() 对象。
from matplotlib import pyplot as plt import numpy as np from mpl_toolkits.mplot3d import Axes3D x = np.random.rand(100) y = np.random.rand(100) z = np.random.rand(100) fig = plt.figure() ax = Axes3D(fig) ax.scatter(x,y,z,s=10,color="r",marker='o') plt.show()
from matplotlib import pyplot as plt import numpy as np from mpl_toolkits.mplot3d import Axes3D zline = np.linspace(0,15,1000) xline = np.sin(zline) yline = np.cos(zline) fig = plt.figure() ax = Axes3D(fig) ax.plot(xline,yline,zline) plt.show()
x = [1,2,3,4]
y = [1,2,3,4]
X, Y = np.meshgrid(x, y)
# 创建画布
fig = plt.figure()
# 创建3D坐标系
ax = Axes3D(fig)
ax.plot_surface(X,
Y,
Z=X+Y
)