Aushöhlung eines Patchs / "Anticlipping" eines Patchs in Matplotlib (Python)Python

Python-Programme
Anonymous
 Aushöhlung eines Patchs / "Anticlipping" eines Patchs in Matplotlib (Python)

Post by Anonymous »

Ich möchte einen Patch in Matplotlib zeichnen, der durch Aushöhlung mit einem anderen Patch ausgestattet ist, so dass der ausgehöhlte Teil vollständig transparent ist. Ich könnte Folgendes machen: < /p>

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)
würde den Trick machen, aber ich konnte so etwas nicht finden.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post