On 2014/08/28, 3:02 AM, Matthew Czesarski wrote: > Hi Matplotlib Users! > > > > I have some 2-d arrays, which i am displaying with implot, and deriving > contours for with contour. Easy - I'm just pulling them out of > collections[0].get_paths() . > > However what's not easy is that I would like to recover a 1-0 or > True-False array of the array values (pixels) that fall within the > contours. Some line crossing algorithm/floodfill could do it, but I > guess that matplotlib's fill() or contourf() must do this under the hood > anyway. I've looked into the output both functions, but I don't see > anything obvious.. > > Does anybody know if there's an a way to pull out a such an array from > matplotlib? Any pointers are appreciated!
Make an array of (x, y) pairs from the X and Y you use in your call to contour, and then feed that array to the contains_points() method of your contour Path. This will give you the desired Boolean array for any given Path; depending on what you want, you might need to combine arrays for more than one Path. To get closed paths, I think you will want to use contourf, not contour. Eric > > Cheers, > Matt > > > ------------------------------------------------------------------------------ > Slashdot TV. > Video for Nerds. Stuff that matters. > http://tv.slashdot.org/ > > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users