简体   繁体   中英

Creating surface in matplotlib throw on lines

I try to create curved surface throw on 3 lines. Each line is defined in 3 points( each point have coordinate(x, y, z) )

first line: (0, 0, 10) (0, 5, 5) (0, 10, 2)

second line: (2, 0, 10) (2, 5, 5) (2, 10, 2)

third line: (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()

I'm getting this image 我的实际形象

But I need image like this: 在此处输入图片说明

plot_trisurf is resolved my issue.

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()

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM