Reputation: 193
I used the following code to overlay a polygon on top of an image. But I do not want to fill the polygon. How can I achieve it?
polygon = [];
for prop in props:
polygon.append([int(prop.centroid[1]), int(prop.centroid[0])])
track = optimized_path(polygon)
fig = plt.figure(0)
ax = fig.add_subplot(1, 1, 1)
ax.imshow(bg[:, :, (2, 1, 0)])
ax.add_patch(plt.Polygon(track, ))
plt.show()
Upvotes: 2
Views: 1038
Reputation: 1351
Use the facecolor and edgecolor properties, which can be abbreviated to fc and ec. Set facecolor to none, and then the edgecolor to what you want the outline to be.
plt.Polygon(track, fc='none', ec='orangered')
Can also change the linewidth property (lw) to make the line thicker or thinner
plt.Polygon(track, fc='none', ec='orangered', lw=3)
Upvotes: 2