On Wed, Nov 11, 2009 at 3:22 PM, Shrividya Ravi <penthesel...@gmail.com> wrote:
> Thanks for your reply, Giorgio. I had a look at the documentation for pcolor
> but unfortunately, I can't pick out where I have gone wrong. I have attached
> my data array as a txt file. In ipython, I use the 'loadtxt' command to load
> the dataset and then assigned the variables x,y, and z to the first, second
> and third columns respectively. I then specified the meshgrid X,Y from the x
> and y arrays of my data and used pcolor(X,Y,z) to try and plot the color
> map.

You have to interpolate your 1D data onto a 2D grid --

# first load the data
In [504]: x,y,z = np.loadtxt('195pt52_T6.txt', unpack=True)

# create evenly sampled x and y vectors to interpolate onto
In [505]: xi = np.linspace(x.min(), x.max(), 20)

In [506]: yi = np.linspace(y.min(), y.max(), 20)

# use griddata to do the 2D interoplation
In [507]: Z = mlab.griddata(x, y, z, xi, yi)

In [508]: Z.shape
Out[508]: (20, 20)

# use meshgrid to create 2D grids of your 1D x and 1 data
In [509]: X, Y = np.meshgrid(xi, yi)

# pass all the 2D arrays to pcolor
In [510]: pcolor(X, Y, Z)
Out[510]: <matplotlib.collections.PolyCollection object at 0x113e6d8c>



Hope this helps!

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to