How to make clipping work with basemap and contourf

Hi,

I've been attempting to get basemap to clip a contourf display. I have not
had any luck! Attached is a self contained example. Could somebody kindly
point out what I am doing wrong!?!

If I remove the zorder settings, I get no data plotted!

The goal is to clip my contourf plots by political boundaries. I am
using a simple rectangle at the moment for illustration.

thanks,
  daryl

contourf_clip.py (3.06 KB)

Hi Daryl,

You were almost there. Remove the call to mask_outside_polygon and replace it with
for collection in cs.collections:
collection.set_clip_path(patch)

Attached is your corrected example and the output produced.

Ian

contourf_clip.py (1.67 KB)

test.png

···

On 29 October 2012 14:50, Daryl Herzmann <akrherz@…287…> wrote:

I’ve been attempting to get basemap to clip a contourf display. I have not

had any luck! Attached is a self contained example. Could somebody kindly

point out what I am doing wrong!?!