我想在同一个图中绘制线框和散点图。我要做的是:
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax1 = fig.add_subplot(111, projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
ax1.plot_wireframe(X, Y, Z, rstride=10, cstride=10)
ax2 = fig.add_subplot(111, projection='3d')
xs = np.array( [ 1, 0 ,2 ])
ys = np.array( [ 1, 0, 2 ])
zs = np.array( [ 1, 2, 3 ])
ax2.scatter(xs, ys, zs)
plt.show()
这个脚本只是给出了散点图。注释任何块,就得到未注释的绘图。但他们不会在一起搞同一个阴谋。在
当您再次
add_subplot(111)
时,您将重写上一个子批。只是不要这样,在同一个轴上画两次:相关问题 更多 >
编程相关推荐