lundi 28 septembre 2015

How to create random color to fill a circle? Running Python in bash terminal mac

the equation for my circle is

 circle1 = plt.Circle((0,0),0.5, color ="r", alpha=0.75)

here, the r represents red however I'm wondering if its possible to fill the circle with a random color.

I've tried (after importing random)

 COLORS = [(139, 0, 0), 
          (0, 100, 0),
          (0, 0, 139)] 
 circle1 = plt.Circle((0,0),0.5, color='random.choice(COLORS)', alpha=0.75)

and I have tried

 nums = map(lambda x : random.randint(0,7), range(50))
 cols = map(lambda i: colour[i], nums)
 circle1 = plt.Circle((0,0),0.5, color='cols', alpha=0.75)

but I havent had any luck yet. any help would be greatly appreciated! Thanks




Aucun commentaire:

Enregistrer un commentaire