title: 3D convex hull from point cloud
body: <p>I need to plot a 3D point cloud (number of points: N), then a convex hull (actually a polyhedron with N vertices) from the points. I made a script in python with scipy.spatial ConvexHull for plot 8 points and plot a cube, the plot of the point cloud is ok, but the cube is not ok, because the code puts two lines going across the diagonal face of the cube in addition to the edge lines. I don't understand why plot lines across faces.</p>
  
  <p>The script:</p>
  
  <pre><code>import numpy as np
  from mpl_toolkits.mplot3d import Axes3D
  import matplotlib.pyplot as plt
  from scipy.spatial import ConvexHull  
  
  fig = plt.figure()
  ax = fig.add_subplot(111, projection='3d')
  
  points= np.array([[0,0,0],
              [4,0,0],
              [4,4,0],
              [0,4,0],
              [0,0,4],
              [4,0,4],
              [4,4,4],
              [0,4,4]])
  
  hull=ConvexHull(points)
  
  edges= zip(*points)
  
  for i in hull.simplices:
      plt.plot(points[i,0], points[i,1], points[i,2], 'r-')
  
  ax.plot(edges[0],edges[1],edges[2],'bo') 
  
  ax.set_xlabel('x')
  ax.set_ylabel('y')
  ax.set_zlabel('z')
  
  ax.set_xlim3d(-5,5)
  ax.set_ylim3d(-5,5)
  ax.set_zlim3d(-5,5)
  
  plt.show()
  </code></pre>
  
  <p>Result of the script:</p>
  
  <p><img src="https://i.stack.imgur.com/YTtPc.png" alt="enter image description here"></p>