plotting a contour from dicrete data points

hello ppl,
hey i hav 3 .dat files… one has 1 column of x coords, another has 1 column of the same number of y coords and the last .dat file has the same number of corresponding values of a property[temperature] at those points in 1 column… i was wondering how i cud make a contour of this data with the last .dat file being the z-values… i hav written the following code(
saf2.py)[mind u ppl am a newbie @ python+matplotlib]…

from pylab import *

x = load(‘xcord2.dat’)
y = load(‘ycord2.dat’)
X, Y = meshgrid(x, y)

Z = load(‘output1im.dat’)

contour(X,Y,Z)
show()

the following errors crop up:

Traceback (most recent call last):
File “F:\Python25\saf2.py”, line 9, in
contour(X,Y,Z)
File “F:\Python25\Lib\site-packages\matplotlib\pylab.py”, line 1776, in contour

ret =  gca().contour(*args, **kwargs)

File “F:\Python25\Lib\site-packages\matplotlib\axes.py”, line 4674, in contour
return ContourSet(self, *args, **kwargs)
File “F:\Python25\Lib\site-packages\matplotlib\contour.py”, line 429, in init

x, y, z = self._contour_args(*args)        # also sets self.levels,

File “F:\Python25\Lib\site-packages\matplotlib\contour.py”, line 601, in _contour_args
x,y,z = self._check_xyz(args[:3])
File “F:\Python25\Lib\site-packages\matplotlib\contour.py”, line 577, in _check_xyz
raise TypeError(“Input z must be a 2D array.”)
TypeError: Input z must be a 2D array.

wat errors am i making?

My understanding is the "contour" method only handles plots of functions, e.g. f(x,y) = z, and not discrete points. I tried looking into this weeks ago, and couldn't find a way to handle discrete points.

I'd love to be able to do Kriging or Inverse Distance Weighting contour lines on XY points I have of pollution concentrations at various monitors...

Michael Newman wrote:

My understanding is the "contour" method only handles plots of functions, e.g. f(x,y) = z, and not discrete points. I tried looking into this weeks ago, and couldn't find a way to handle discrete points.

I'd love to be able to do Kriging or Inverse Distance Weighting contour lines on XY points I have of pollution concentrations at various monitors...

Michael: There are three different methods for doing this described at

http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328

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…

···

On 7/3/07, Jeff Whitaker <jswhit@…146…> wrote:

Michael Newman wrote:

My understanding is the “contour” method only handles plots of
functions, e.g. f(x,y) = z, and not discrete points. I tried looking
into this weeks ago, and couldn’t find a way to handle discrete points.

I’d love to be able to do Kriging or Inverse Distance Weighting contour
lines on XY points I have of pollution concentrations at various monitors…

Michael: There are three different methods for doing this described at

http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

-Jeff


Jeffrey S. Whitaker Phone : (303)497-6313

NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328


This SF.net email is sponsored by DB2 Express

Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Viraj Vajratkar wrote:

    Michael Newman wrote:
    > My understanding is the "contour" method only handles plots of
    > functions, e.g. f(x,y) = z, and not discrete points. I tried looking
    > into this weeks ago, and couldn't find a way to handle discrete
    points.
    >
    > I'd love to be able to do Kriging or Inverse Distance Weighting
    contour
    > lines on XY points I have of pollution concentrations at various
    monitors...
    >
    Michael: There are three different methods for doing this
    described at

    http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

    -Jeff

    --
    Jeffrey S. Whitaker Phone : (303)497-6313
    NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
    325 Broadway Boulder, CO, USA 80305-3328

    -------------------------------------------------------------------------
    This SF.net email is sponsored by DB2 Express
    Download DB2 Express C - the FREE version of DB2 express and take
    control of your XML. No limits. Just data. Click to get it now.
    http://sourceforge.net/powerbar/db2/
    <http://sourceforge.net/powerbar/db2/>
    _______________________________________________
    Matplotlib-users mailing list
    Matplotlib-users@lists.sourceforge.net
    <mailto:Matplotlib-users@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/matplotlib-users

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

···

On 7/3/07, *Jeff Whitaker* <jswhit@…146… > <mailto:jswhit@…146…>> wrote:

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328