-1

I need to coloring an Ellipse with two different colors. This could be done half and half or better, an horizontal gradient.

I would like to keep using matplotlib patches and not to use equations to draw the ellipse.

I'm using this minimal code to point the problem.

import matplotlib.pyplot as plt
import matplotlib.patches as mpatch

ax = plt.subplot(111)
ax.add_patch(mpatch.Ellipse(xy = [0.5, 0.5], width= 0.75, height=0.5, facecolor = 'blue'))
plt.show()

Anserws to How to draw a filled arc in matplotlib are directed to fill a circle arc except for one that can fill a ellipse arc.

This is a cartoon of what I need

enter image description here

Community
  • 1
  • 1
heracho
  • 590
  • 1
  • 9
  • 28

1 Answers1

-1

The patch arc can draw a semi ellipse, but by default it can not be filled.

I found how to fill and arc in: How to draw a filled arc in matplotlib.

import matplotlib.pyplot as plt
import matplotlib.patches as mpatch

ax = plt.subplot(111)
ax.add_patch(mpatch.Arc(xy = [0.5, 0.5], width= 0.75, height=0.5, angle=.0, theta1= 90.0, theta2=-90.0, color = 'blue', hatch = 'OOOO'))
ax.add_patch(mpatch.Arc(xy = [0.5, 0.5], width= 0.75, height=0.5, angle=.0, theta1=-90.0, theta2= 90.0, color = 'green', hatch = 'OOOO'))

enter image description here

Community
  • 1
  • 1
heracho
  • 590
  • 1
  • 9
  • 28
  • This solution depends on image resolution, whit enough zoom it's possible to notice the points instead of a solid color. – heracho Feb 09 '17 at 23:57