>>[Christophe] Thanks, your example works but what I must do so to plot for example
>> ? I'm a very beginner.
> line, = ax.plot(x, np.cos(x))
> patch = patches.Circle((300,300), radius=100)
>Everything in the matplotlib figure is an "Artist" (lines, images,
>text, rectangles) and you can set the clippath of any artist. See
This is a very timely question for me. I'm needing to do something very similar, but I need to overlay a semi-transparent rectangle with a hole cut out of it. So, I'm making a rectangular patch, making a circular patch, setting the circular patch as the clip region for the rectangular patch, and then adding the clipped patch to the plot. However, I seem to be having trouble with the coordinate system, as there is no clipping on the rectangle.
My test code looks like this:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.path as path
import matplotlib.patches as patches
fig = plt.figure()
ax = fig.add_subplot(111)
x = np.arange(-50,50,0.1)
line, = ax.plot(x, np.cos(x)*50)
r=patches.Rectangle((-10,-10), 20, 20, fc=(0.5,0.5,0.5,0.9))
# shouldn't one of these work?
# Plot coordinate system
cutout = patches.Circle((0,0), radius=10)
# Window coordinate system
#~ cutout = patches.Circle((300,300), radius=50)