Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug report
Bug summary
Cartopy has a mostly-superfluousGeoAxes.background_patch
which I'm trying to convert to the standardAxes.patch
. By default, theAxes.patch
is aRectangle
, which triggers a fast-path to set a clip box instead of a clip path. However, since most map boundaries are non-square, the full clip path code is used instead. When doing so, this causes some strange artifacts.
(Un)Fortunately, it can be reproduced with plain Matplotlib below.
Code for reproduction
importmatplotlib.pyplotaspltimportmatplotlib.patchesasmpatchesfrommatplotlib.collectionsimportPatchCollectionfrommatplotlib.pathimportPathpth=Path([[0,0], [1,0], [1,1], [0,1], [0,1]], [1,2,2,2,79])fig,ax=plt.subplots(2,2,sharex=True,sharey=True)ax[0,0].set_xlim(-1,2)ax[0,0].set_ylim(-1,2)forainax[0]:collection=a.add_collection(PatchCollection([mpatches.PathPatch(pth)],facecolor='C0',edgecolor='k'))collection.set_clip_path(Path([[0,0], [1,0], [1,1], [0,1], [0,1]]),a.transAxes)forainax[1]:patch=a.add_patch(mpatches.PathPatch(pth,facecolor='C0',edgecolor='k'))patch.set_clip_path(Path([[0,0], [1,0], [1,1], [0,1], [0,1]]),a.transAxes)ax[0,0].set_ylabel('PatchCollection')ax[1,0].set_ylabel('PathPatch')ax[1,0].set_xlabel('Default clip box')ax[1,1].set_xlabel('Custom clip path')plt.savefig('test.png')
Actual outcome
In the bottom row is a plainPathPatch
, and the top row is aPatchCollection
containing the samePathPatch
. The left column shows the default clipping (to the clip box of theAxes
). The right column uses a clip path of a manually-specified 0-1 rectangle inAxes
space, so it should be equivalent.
But the horizontal edges are either doubled over or the wrong width in the top-right case.
Expected outcome
All path edges should look the same.
Matplotlib version
- Operating system: Fedora 30
- Matplotlib version: 3.1.3 and master,9d00ca8
- Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg (probably only the Agg bit is relevant) - Python version: 3.6.9 / 3.6.3