Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed as not planned
Labels
Milestone
Description
I am trying to plot a circle patch clipped by a rectangular patch that has been transformed, for example by a rotation. However, the clipping doesn't seem to be working right. First, here's what it looks like without rotation:
frommatplotlibimportpyplotaspltfrommatplotlib.transformsimportAffine2Dfrommatplotlib.patchesimportCircle,Rectanglefig=plt.figure()ax=fig.add_subplot(1,1,1,aspect='equal')r=Rectangle((-1,-3),2,6,facecolor='none',edgecolor='none')ax.add_patch(r)c=Circle((0,0),radius=2,edgecolor='none',facecolor='0.75')ax.add_patch(c)c.set_clip_path(r)ax.set_xlim(-3,3)ax.set_ylim(-3,3)fig.savefig('circles_norot.png')
If I then replace the definition of the patches with:
rotation=Affine2D().rotate(1.5)+ax.transDatar=Rectangle((-1,-3),2,6,facecolor='none',edgecolor='none',transform=rotation)ax.add_patch(r)c=Circle((0,0),radius=2,edgecolor='none',facecolor='0.75',transform=rotation)ax.add_patch(c)c.set_clip_path(r)
I get:
which doesn't look right (the width of the dark grey shouldn't change, and should be rotated 1.5 radians
compared to original example above).