title: Creating a Triangulation for use in Matplotlib's plot_trisurf with matplotlib.tri.Triangulation
body: <p>I am a trying to use <code>matplotlib.tri.Triangulation</code> to generate the triangles for a matplotlibs <code>plot_trisurf</code>. I want to specify the triangles rather than letting the Delaunay triangulation which <code>matplotlib.tri.Triangulation</code> uses because it does not work for some cases such as triangles in in the xz or yz plane. I am not sure if this specifying the triangles myself will solve the problem but I seems like a good thing to try.</p>
  
  <p>The issue is that the triangulation requires a (n,3) array with n being the number of triangles. To quote the page on matplotlib.org "For each triangle, the indices of the three points that make up the triangle, ordered in an anticlockwise manner." <a href="https://matplotlib.org/api/tri_api.html#matplotlib.tri.Triangulation" rel="nofollow noreferrer">https://matplotlib.org/api/tri_api.html#matplotlib.tri.Triangulation</a>
  . I cannot discern how to create the array in the right form and that is were I would like help. I appreciate any help.</p>
  
  <p>I have tried a few things so far but here is what my last try looks like:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  import matplotlib.tri as mtri
  
  fig = plt.figure()
  ax = fig.gca(projection='3d')
  
  x1=0
  x2=1
  x3=1
  x4=0
  
  y1=0
  y2=0
  y3=2
  y4=2
  
  x=[]
  y=[]
  x.append(x1)
  x.append(x2)
  x.append(x3)
  x.append(x4)
  y.append(y1)
  y.append(y2)
  y.append(y3)
  y.append(y4)
  z=np.zeros(8)
  
  triang = mtri.Triangulation(x, y, triangles=[[[x1,y1],[x2,y2],[x3,y3]],[[x3,y3],[x4,y4],[x2,y2]]])
  
  ax.plot_trisurf(triang, z, linewidth=0.2, antialiased=True)
  
  ax.view_init(45,-90)
  ax.set_xlabel("X")
  ax.set_ylabel("Y")
  ax.set_zlabel("Z")
  ax.set_aspect("equal")
  
  fig.set_size_inches(8,8)
  
  plt.show()
  </code></pre>