From: Mike H. <mh...@us...> - 2008-12-03 21:12:39
|
>>I don't think this is going to make it easy to do what you want It might if I could find the x,y data in the LineCollection objects. There is an undocumented function in the LineCollection class called get_paths(), which looks like it returns a list of Path objects. These path objects have a vertices property which looks like the stuff I want. I'll explore this for a while. Anyone who knows more about these objects, feel free to chime in! Thanks, Mike Eric Firing <ef...@ha...> 12/03/08 01:59 PM To Mike Hearne <mh...@us...> cc mat...@li... Subject Re: [Matplotlib-users] Contour line data Mike Hearne wrote: > > How can I get the actual x,y data that represents the contour lines that > are drawn with the contour() function? > > I'd like to be able to redraw portions of those lines with different > styles (dashed, dotted, etc.) > > For example, given the following sample code (lifted from the > sourceforge example): > > from pylab import * > from numpy import * > > delta = 0.025 > x = arange(-3.0, 3.0, delta) > y = arange(-2.0, 2.0, delta) > X, Y = meshgrid(x, y) > Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) > Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1) > # difference of Gaussians > Z = 10.0 * (Z2 - Z1) > figure() > cs = plt.contour(X, Y, Z) > show() > > How could I, for example, re-draw the lines in the region X [0 1] Y > [-1.5 -0.5] as dashed? > > I could do it, I think, if I had the for all the lines in the plot. I don't think this is going to make it easy to do what you want, but cs.collections is a list of LineCollection objects corresponding to the contour levels in cs.levels. Eric |