From: Eric F. <ef...@ha...> - 2008-12-03 21:00:14
|
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 |