我尝试在3条线上创建曲面投掷。 每条线定义为3个点(每个点都有坐标(x,y,z))
第一行: (0,0,10) (0,5,5) (0,10,2)
第二行: (2,0,10) (2,5,5) (2,10,2)
第三行: (4,1,10) (4,6,5) (4,11,2)
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
x = [0, 2, 4, 0, 2, 4, 0, 2, 4]
y = [0, 0, 1, 5, 5, 6, 10, 10, 11]
z = [10, 10, 10, 5, 5, 5, 2, 2, 2]
X = x
Y = y
Z = z
Y, X = np.meshgrid(Y, X)
ax.plot_wireframe( X, Y, Z)
plt.show()
我正在收到这张照片
但我需要这样的图像:
答案 0 :(得分:2)
plot_trisurf解决了我的问题。
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
x = [0, 2, 4, 0, 2, 4, 0, 2, 4]
y = [0, 0, 1, 5, 5, 6, 10, 10, 11]
z = [10, 10, 10, 5, 5, 5, 2, 2, 2]
X = x
Y = y
Z = z
ax.plot_trisurf( X, Y, Z)
plt.show()