matplotlibtriplot

how to specify edge colors with triplot


In the following example using matplotlib.triplot, how I can specify the edge colors to have color, say, 0xFFAC67?

import matplotlib.pyplot as plt
import matplotlib.tri as tri
import numpy as np
xy = np.asarray([ [0.2, 0.1], [0.9, -0.1], [1.2, 1.29] ])
x = np.degrees(xy[:, 0])
y = np.degrees(xy[:, 1])
triangles = np.asarray([ [0, 1,  2] ])
mesh = tri.Triangulation( x, y, triangles )
plt.figure()
plt.gca().set_aspect('equal')
plt.triplot( mesh, 'g-', lw=1.0 )
plt.show()

Solution

  • You can specify the color using the parameter c. The color you specified was invalid but replacing 0x by # works as follows

    plt.gca().set_aspect('equal')
    plt.triplot(mesh, '-', lw=1.0, c='#FFAC67')
    plt.show()
    

    enter image description here