On Tue, Oct 16, 2012 at 4:04 PM, T J <[email protected]> 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?
QuadContourSet does not (I think it should), but LineCollection
instances in QuadContourSet.collections does. Below is a quick
example.
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(100)-50
arr = (x**2 + x[:,np.newaxis]**2)**.5
cont = plt.contour(arr)
col1 = cont.collections[3] # contour line to clip with.
clip_path = col1.get_paths()[0] # Note that col1 may have multiple paths.
for col in cont.collections:
col.set_clip_path(clip_path, col1.get_transform()) # set clip_path
for individual LineCollection instances.
plt.show()
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users