Well, this is not quite the answer to the problem using Matplotlib, but I abandoned this library for this work and just used PIL.
This is pretty easy, albeit pretty slow (but I don't know, slower than Matplotlib).
The code is as follows:
def makeImage (triangle, largura, altura): """ triangle: receives a tuple in the form: x1, y1, x2, y2, x3, y3, R, G, B, A largura: image weight altura: image height returns: numPy array of the triangle composed final image """ back = Image.new('RGBA', (largura,altura), (0,0,0,0)) poly = Image.new('RGBA', (largura,altura)) pdraw = ImageDraw.Draw(poly) pdraw.polygon([1,2,3,4,5,6], fill=(255,0,0,127)) back.paste(poly,mask=poly) back = back.convert('RGB') backArr = asarray(back)
If you know a way to expedite this process, please let me know.
source share