matplotlib - Python matplot : how to quickly plot multiple 3D lines -


everyone, have pairs of 3d points, endpoints line segments. such as

x = [ [x1,x2], [,],...] y = [ [y1,y2], [,],...] z = [ [z1,z2], [,],...] 

line segment:

[x1,y1,z1] point1, [x2,y2,z2] points2 

i use follow code plot 3d lines:

import numpy np import matplotlib import matplotlib.pyplot plt mpl_toolkits.mplot3d import axes3d import random  line_segment = [] # generate endpoints line segments xpairs = [] ypairs = [] zpairs = [] in range(2000):   xends = [random.random(), random.random()]   yends = [random.random(), random.random()]   zends = [random.random(), random.random()]   xpairs.append(xends)   ypairs.append(yends)   zpairs.append(zends)  ## plot 3d fig = plt.figure() plt.ion() ax = fig.gca(projection='3d') ax.clear()     ax.grid('off')  ## slow xends,yends,zends in zip(xpairs,ypairs,zpairs):  ax.plot( xends , yends ,zends )  ## how use ??? matplotlib.collections import linecollection  plt.show() 

pic:

enter image description here

however, method slow when want plot large collection of line segments.

i found recommend matplotlib.collections plot multi 2d lines

from matplotlib.collections import linecollection 

but, dont know how use in 3d plot.

i find useful bolg introduce 4 methods plot multi lines, unfortunately, it's 2d line plot.

can me figure out how plot multi 3d lines quickly? thanks.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -