Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## matplotlib-users

 Re: [Matplotlib-users] plotting a contour from dicrete data From: Mark Bakker - 2007-07-11 09:37:04 Attachments: Message as HTML ```Viraj and Jeff - Maybe one extension of Jeff's answer. The process works as long as x, y, and z are 2D arrays of the same size and shape. Hence, x and y don't have to form a rectangular grid. I have used this feature regularly for conformal mapping. And it makes a lot of sense. The contour routine simply looks for intersections between x and y values. Then when it plots it uses the x and y values in the arrays. So when those are not a rectangular grid, it doesn't care. It's a cool feature. I can give an example if you want, Mark Viraj Vajratkar wrote: > > hey guys... i got it... u can use contour(x,y,z)... as in > > x=load('urfile1.dat'), y=load('urfile2.dat), z=load('urfile3.dat > > ').... and then type out the above.... for details about the > > parameters x,y,z see... . > > http://www.scilab.org/product/man-eng/graphics/contour.htm .... so > > matplotlib CAN plot a contour from discrete points!!!.... ive tried it > > and it works... > Viraj: That only works because x and y describe a rectangular grid. If > x and y described irregularly spaced points, you would need to grid the > data first using one of the methods described on that Cookbook page. > > -Jeff > ```
 Re: [Matplotlib-users] plotting a contour from dicrete data From: Mark Bakker - 2007-07-11 11:07:59 Attachments: Message as HTML ```I thought it was cool the first time I saw it. Just try something simple from pylab import * x,y = meshgrid(linspace(-5,5,101),linspace(0,5,101)) h = y z = x + complex(0,1)*y znew = z**0.25 # Doing a simple conformal map xnew = znew.real ynew = znew.imag contourf(xnew,ynew,h,linspace(0,5,10)) axis('scaled') And you get nice contours in a pieslice-shaped domain with an angle of 45 degrees Mark From: "Scott Sinclair" > > That is very cool, I hadn't thought of it! > > So what you're saying is that any transformation (a complex distortion) of > a regular rectangular grid is fine. The fact that the grid's 'pixels' are > four sided quadrilaterals satisfies this condition and the contour algorithm > works... > > Cheers, > Scott > > >>> "Mark Bakker" 7/11/2007 11:36 >>> > Viraj and Jeff - > > Maybe one extension of Jeff's answer. > The process works as long as x, y, and z are 2D arrays of the same size > and shape. > Hence, x and y don't have to form a rectangular grid. > I have used this feature regularly for conformal mapping. > And it makes a lot of sense. > The contour routine simply looks for intersections between x and y values. > Then when it plots it uses the x and y values in the arrays. > So when those are not a rectangular grid, it doesn't care. > It's a cool feature. > I can give an example if you want, > > Mark > ```
 Re: [Matplotlib-users] plotting a contour from dicrete data From: Scott Sinclair - 2007-07-11 10:37:26 Attachments: Message as HTML ```That is very cool, I hadn't thought of it! =20 So what you're saying is that any transformation (a complex distortion) of = a regular rectangular grid is fine. The fact that the grid's 'pixels' are = four sided quadrilaterals satisfies this condition and the contour = algorithm works... =20 Cheers, Scott >>> "Mark Bakker" 7/11/2007 11:36 >>> Viraj and Jeff - Maybe one extension of Jeff's answer. The process works as long as x, y, and z are 2D arrays of the same size = and shape. Hence, x and y don't have to form a rectangular grid.=20 I have used this feature regularly for conformal mapping.=20 And it makes a lot of sense.=20 The contour routine simply looks for intersections between x and y values. Then when it plots it uses the x and y values in the arrays.=20 So when those are not a rectangular grid, it doesn't care. It's a cool feature. I can give an example if you want, Mark =20 Viraj Vajratkar wrote: > hey guys... i got it... u can use contour(x,y,z)... as in > x=3Dload('urfile1.dat'), y=3Dload('urfile2.dat), z=3Dload('urfile3.dat > ').... and then type out the above.... for details about the=20 > parameters x,y,z see... . > http://www.scilab.org/product/man-eng/graphics/contour.htm .... so > matplotlib CAN plot a contour from discrete points!!!.... ive tried = it=20 > and it works... Viraj: That only works because x and y describe a rectangular grid. If x and y described irregularly spaced points, you would need to grid the data first using one of the methods described on that Cookbook page.=20 -Jeff Please find our Email Disclaimer here: http://www.ukzn.ac.za/disclaimer/ ```
 Re: [Matplotlib-users] plotting a contour from dicrete data From: Jeff Whitaker - 2007-07-11 12:04:30 ```Mark Bakker wrote: > Viraj and Jeff - > > Maybe one extension of Jeff's answer. > The process works as long as x, y, and z are 2D arrays of the same > size and shape. > Hence, x and y don't have to form a rectangular grid. > I have used this feature regularly for conformal mapping. > And it makes a lot of sense. > The contour routine simply looks for intersections between x and y values. > Then when it plots it uses the x and y values in the arrays. > So when those are not a rectangular grid, it doesn't care. > It's a cool feature. > I can give an example if you want, > > Mark > > > > Viraj Vajratkar wrote: > > hey guys... i got it... u can use contour(x,y,z)... as in > > x=load('urfile1.dat'), y=load('urfile2.dat), z=load('urfile3.dat > > ').... and then type out the above.... for details about the > > parameters x,y,z see... . > > http://www.scilab.org/product/man-eng/graphics/contour.htm .... so > > matplotlib CAN plot a contour from discrete points!!!.... ive > tried it > > and it works... > Viraj: That only works because x and y describe a rectangular > grid. If > x and y described irregularly spaced points, you would need to > grid the > data first using one of the methods described on that Cookbook page. > > -Jeff > > Mark: That is cool - didn't know it could do that. So I guess the proper answer is contour requires x and y to describe a *regular*, but not recessarily rectilinear, grid. I should have known, since there is an example in basemap (ccsm_popgrid.py) that illustrates this. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 325 Broadway Boulder, CO, USA 80305-3328 ```