Code: Select all
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
ellipse_1 = Ellipse((0,0), 4, 3, color='blue')
ellipse_2 = Ellipse((0.5,0.25), 2, 1, angle=30, color='white')
ax = plt.axes()
ax.add_artist(ellipse_1)
ax.add_artist(ellipse_2)
plt.axis('equal')
plt.axis((-3,3,-3,3))
plt.show()
, wenn ich jetzt etwas hinter dem ausgehöhlten Teil des ausgehöhlten Teils zu zeichnen wollte:
Code: Select all
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse, Rectangle
ellipse_1 = Ellipse((0,0), 4, 3, color='blue')
ellipse_2 = Ellipse((0.5,0.25), 2, 1, angle=30, color='white')
rectangle = Rectangle((-2.5,-2), 5, 2, color='red')
ax = plt.axes()
ax.add_artist(rectangle)
ax.add_artist(ellipse_1)
ax.add_artist(ellipse_2)
plt.axis('equal')
plt.axis((-3,3,-3,3))
plt.show()
, wobei der Teil des roten Rechtecks in der blauen Form nicht ersichtlich ist. Gibt es eine einfache Möglichkeit, dies zu tun?
Eine andere Möglichkeit, dies zu lösen
Code: Select all
ellipse_1.set_anticlip_path(ellipse_2)