title: Fill matplotlib polygon with a gradient between vertices
body: <p>I'm plotting a collection of polygons (triangles) using matplotlib's Poly3DCollection. The triangles are between vertices with a color associated with them. I'm currently filling each triangle with a solid color determined by averaging the colors of the three vertices. The triangles are plotted to form a 3D surface mesh.</p>
  <p>I would like to fill the triangle with a gradient between all three vertices. The pixel color at a given point would ideally just be linearly interpolated based on the distance to the three points. For example, if there vertices are blue, green and red, the resulting triangle should look like this:<br />
  <a href="https://i.stack.imgur.com/i4fgj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i4fgj.jpg" alt="enter image description here" /></a></p>
  <p>I think this should be possible using matplotlib, but I'm not sure how to do it. If it's not possible, could you suggest another library or approach I could use? Thanks for your help.</p>
  <p>EDIT: Additional details</p>
  <p>It should work for an arbitrary number of triangles but likely to be less than 2000. The colors are arbitrary, although each vertex will only have one color associated with it. The collection of polygons is created from a list of vertices <code>[x_1, y_1, z_1, x_2, y_2, z_2...]</code>. I can easily change this format as required. The colors associated with each vertex are in a separate list, this can also be easily changed.</p>