0

I'm following this tutorial by Matplotlib about patches. I understand how it works, but the only thing i don't understand is how can i set color to the patches. Say i want all of them to be orange, i tried this (from the code):

for x1, y1, r, t1, t2 in zip(x, y, radii, theta1, theta2):
    wedge = Wedge((x1, y1), r, t1, t2, color='orange')
    patches.append(wedge)

But it didn't set the color to the patches. How can i do that?

San9096
  • 231
  • 4
  • 12
  • @JohanC the code is exactly the same as the example i linked; i only wanted to set the colors myself, but rest of the code is the same – San9096 Jun 22 '20 at 09:52

1 Answers1

2

you need to specify match_original=True (and of course comment out the line p.set_array(np.array(colors))). From the docs:

match_original
If True, use the colors and linewidths of the original patches. If False, new colors may be assigned by providing the standard collection arguments, facecolor, edgecolor, linewidths, norm or cmap.

p = PatchCollection(patches, alpha=0.4, match_original=True)
Stef
  • 28,728
  • 2
  • 24
  • 52