I have an ellipse that I want to fill with colors in different sections. To achieve this I'm using arcs within this ellipse. I'm sure there is a more efficient way but I'm currently drawing multiple arcs and using zorder to overlap the appropriate arcs. For instance, below arc1 and arc2 are plotted separately but are considered as a single area. They overlap arc3. The code below fills one half of the ellipse with two colors. I would replicate this to fill the other side.
But it's not completely filling the ellipse even when plotting multiple arcs.
I'm also having to use hatch, which limits the parameters I can use for different formatting. As in not completely filling, while eliminating alpha
I'm also hoping to map values with a reference colormap ranging from 0-1. So the area being covered by arc1 and arc2 may have a reference value of 0.5, while arc3 may be 1.
Is it possible to achieve this or will another method be required?
import matplotlib.pyplot as plt
import matplotlib as mpl
import math
fig, ax = plt.subplots(figsize = (8,5))
ax.grid(False)
ax.set_xlim(-80,80)
ax.set_ylim(-70,70)
Arc1_xy = -68, 0
Arc2_xy = -48,0
Arc3_xy = 15, 0
E_xy = 0,0
angle = math.degrees(math.acos(2/9.15))
Arc1 = mpl.patches.Arc(Arc1_xy, 75, 92, angle = 360, theta2 = angle, theta1 = 360-angle, color = 'w', lw = 1, alpha = 1, hatch = 'oooooo', zorder = 10)
Arc2 = mpl.patches.Arc(Arc2_xy, 64, 94, angle = 180, theta2 = angle, theta1 = 360-angle, color = 'w', lw = 1, alpha = 1, hatch = 'oooooo', zorder = 10)
Arc3 = mpl.patches.Arc(Arc3_xy, 190, 132, angle = -180, theta2 = angle, theta1 = 360-angle, color = 'w', lw = 1, alpha = 1, hatch = 'oooooo', zorder = 1)
Ellipse = mpl.patches.Ellipse(E_xy, 160, 130, lw = 1, color = 'white', alpha = 1, fill = False)
ax.add_patch(Arc1)
ax.add_patch(Arc2)
ax.add_patch(Arc3)
ax.add_patch(Ellipse)
Arc1.set_color('green')
Arc2.set_color('green')
Arc3.set_color('blue')
from Fill between arc patches - Matplotlib
No comments:
Post a Comment