Re: [Matplotlib-users] Clipping a plot inside a polygon

2013-09-03 Thread Phil Elson
Sadly each keyword is handled manually in lib/matplotlib/contour.py L690 which is why you can set keywords which are completely ignored without getting any warning/exception. We could add a set_clip_path keyword in that constructor, but in truth the whole keyword handling approach in contour.py cou

Re: [Matplotlib-users] Clipping a plot inside a polygon

2013-09-02 Thread Alex Goodman
Actually, sorry for the triple post, but is there a reason why we can't do something like pass in the keyword arguments directly from the call to contourf when instantiating each collection? Then the keyword arguments for contourf (and ContourSet) could be used for the collections directly, includi

Re: [Matplotlib-users] Clipping a plot inside a polygon

2013-09-02 Thread Alex Goodman
Actually, it seems I have partially answered my own question. Since I am calling axis('off'), I do not notice the effect of clipping the other artists since I made a call to axis('off'). Without it the spines and axes rectangle are still removed but the ticks are still visible. I suppose this is fi

Re: [Matplotlib-users] Clipping a plot inside a polygon

2013-09-02 Thread Alex Goodman
Hi Phil, Thanks, that is more or less what I was looking for. However, I still think that generalizing this approach for other types of plotting functions that don't return artists directly would be useful. Your solution gave me another idea for doing this, which would be to iterate through all of

Re: [Matplotlib-users] Clipping a plot inside a polygon

2013-09-02 Thread Phil Elson
Great question. The contour set itself does not have a set_clip_path method but you can iterate over each of the contour collections and set their respective clip paths, i.e.: cs = plt.contourf(data) for collection in cs.collections: collection.set_clip_path(poly) Of course, you can use this

[Matplotlib-users] Clipping a plot inside a polygon

2013-09-01 Thread Alex Goodman
Hi all, I want to be able to plot data on maps (using basemap or cartopy) inside specific regions, eg a single state, province or country. A similar question was asked a long time ago on the mailing list and the suggested solution back then was to read the bounding polygon from a shapefile and the