3

How can I draw circles with different color gradients, that are high at the center of the circle and low towards its borders?

I can draw, say, 3 circles with different facecolors, using the following code -

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches

ellipse1 = patches.Ellipse(xy=(0, 0), width=4, height=4, angle=30, color='r', alpha=0.4)
ellipse2 = patches.Ellipse(xy=(-2, -2), width=4, height=4, angle=30, color='g', alpha=0.4)
ellipse3 = patches.Ellipse(xy=(3, -2), width=4, height=4, angle=30, color='b', alpha=0.4)

fig, ax = plt.subplots() 
ax.set_xlim((-5, 5))
ax.set_ylim((-5, 5))

ax.add_patch(ellipse1)
ax.add_patch(ellipse2)
ax.add_patch(ellipse3)

plt.show()

So I get the following output -

3 flat color cirlces

I want to color the circles with red, green and blue color gradients instead, that are high at the center and low at the borders.

Is there a minimal way to change the existing code to do that?

Avisek
  • 363
  • 1
  • 3
  • 16
  • https://stackoverflow.com/questions/10958835/matplotlib-color-gradient-in-patches – Bruce Chou Jun 02 '17 at 10:37
  • As the question is not really clear about the specific requirements, I think we can close this as a duplicate of https://stackoverflow.com/questions/10958835/matplotlib-color-gradient-in-patches . It may be that the problem here is different, in which case the queston needs to be updated to include a clear problem description, including statements about in how far other question's answers have not helped and the attempted code. – ImportanceOfBeingErnest Jun 02 '17 at 11:53

0 Answers0