File indexing completed on 2026-04-09 07:48:49
0001
0002 """
0003 https://stackoverflow.com/questions/10192011/clipping-in-matplotlib-why-doesnt-this-work
0004
0005 """
0006
0007 import matplotlib.pyplot as plt
0008 from matplotlib.patches import Circle, Rectangle
0009
0010
0011 fig, ax = plt.subplots(1)
0012
0013 rect = Rectangle((-2,-2),4,2, facecolor="none", edgecolor="none")
0014 circle = Circle((0,0),1)
0015
0016 ax.add_artist(rect)
0017 ax.add_artist(circle)
0018
0019 circle.set_clip_path(rect)
0020
0021 plt.axis('equal')
0022 plt.axis((-2,2,-2,2))
0023
0024 fig.show()
0025