On Tue, Oct 16, 2012 at 8:04 AM, T J <tjhn...@gmail.com> wrote:
> I'm interested in clipping the result of plt.contour (and
> plt.contourf) to a patch.  However, QuadContourSet does not have a
> set_clip_path() method.  Is there a way to do this?
>
> Here is an example plot that I have generated.
>
>    http://imgur.com/pybIf
>
> For the curious, it plots contours of a function on the 2-simplex.
> The way I've gone about computing this is, unfortunately, convoluted.
> I generate a regular grid in 2D and treat each point as a projection
> of a 3D probability vector into 2D.  Then, I invert the projection so
> that I have "distributions" and then compute the Z value for each
> point.  The contours are then calculated, but now, I need to clip
> everything outside the triangle, as only points within the triangle
> correspond to actual distributions.
>
> Is there a more direct way to calculate contours on a restricted set?
>
> Thanks.

The contour functions support masked regions. I think that might be
what you're looking for. Since the region you want to mask is a
triangle, maybe even use a masked triangulated contour plot? Here's
the call signature:
http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.tricontour

Does that help?

-- 
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to