Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
292 views
in Technique[技术] by (71.8m points)

python - I have a 3D plot with 4 points, I want one to be the focal point and the other three to have lines connecting them to the focal point

I used scatter3D to plot the points, but it doesn't seem like I can connect them. The cell is the focal point and the inj are the three it should connect to, any suggestions?

fig = plt.figure()
ax = fig.gca(projection='3d')

cell= [1258096.60,11285000.00, 9415.22]
inj_1 = [1267960.80 ,11278335.00,9430.9]       
inj_2 = [1267960.80 ,11278335.00,9441.32] 
inj_3 = [1267960.80 ,11278335.00,9453.99]

inj_cells = cell,inj_1,inj_2,inj_3

for i in inj_cells:
    I = np.array(i[0])
    J = np.array(i[1])
    K = np.array(i[2])
    
    plot = ax.scatter3D(I,J,K)

plt.show()
question from:https://stackoverflow.com/questions/65890123/i-have-a-3d-plot-with-4-points-i-want-one-to-be-the-focal-point-and-the-other-t

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

to draw lines use ax.plot:

fig = plt.figure()
ax = fig.gca(projection='3d')

cell= [1258096.60,11285000.00, 9415.22]
inj_1 = [1267960.80 ,11278335.00,9430.9]       
inj_2 = [1267960.80 ,11278335.00,9441.32] 
inj_3 = [1267960.80 ,11278335.00,9453.99]

inj_cells = cell,inj_1,inj_2,inj_3

c, d, e = cell

for i in inj_cells:
    I = np.array(i[0])
    J = np.array(i[1])
    K = np.array(i[2])
    
    ax.plot((c,I), (d,J), (e,K))

plt.show()

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...