With clip_path set, things inside the clip_path is only drawn. So, I
think you're misusing clip_path.
To draw a rectangle with a hole in it, you need to create a compound
path. And, this requires some understanding of how path system works
Here is modified version of your script that draws a rectangle with a
hole. It concatenates two existing paths. But, often it is better to
start from scratch (but again you need to understand how path works).
And of course, the resulting compound path can be set as a clip_path
of other artist.
from matplotlib import patches
# background line
line = ax.plot( [ 1, 2, 3], [ 1, 2, 3 ] )
# mask polygon that should cover/hide the area not intersecting the
poly_patch = patches.Polygon(((1,1),(1,3),(3,3), (3,1)))
# part I would like to see through
hole_patch = patches.Circle((2,2), radius=.5, facecolor='red')
from matplotlib.bezier import make_path_regular, concatenate_paths
from matplotlib.path import Path
from matplotlib.patches import PathPatch
poly_path = make_path_regular(poly_patch.get_path())
# close the path
closed_polygon_path = Path(list(poly_path.vertices)+[(0,0)],
# circle with coordinate transformed
hole_path = hole_patch.get_path()
# make polygon with a hole
poly_with_hole_path = concatenate_paths([closed_polygon_path,
poly_with_hole_patch = PathPatch(poly_with_hole_path)
On Fri, Mar 12, 2010 at 7:45 AM, othererik <othererik@...287...> wrote:
Here's a short example that does the opposite of what I'm looking for. The
goal is to take a the polygon "poly_patch" and "cut" regions out of it.
All I've managed to achieve so far has been to show regions of the