## Re: [Matplotlib-users] plotting scattered data from array

 Re: [Matplotlib-users] plotting scattered data from array From: Oz Nahum - 2008-09-25 20:20:03 Attachments: Message as HTML >¿What's the meaning of that data arrange? I can't make any sense of >plotting a 2D scatter from a 3D array. when I wrote: head = [[0, 0, 10], [1, 0, 13], [2, 0, 11], [3, 0, 12], [1, 2, 11]] my meaning was to represent point of intereset with x, y coordinates and the 3rd number was height for example. I felt like I couldn't access the individual points easily, because their are located in on big list... So I wanted to have the list broken into rows, and the each row represents a value on the y axis... like this: head = [ [[0, 0, 10], [0, 0, 13]], [[2, 0, 11], [3, 0, 12]], ] But that's redundant I think now, after looking into the function zip. Maybe I could write head in the following way: # j = 0 1 head = [ [[ 0, 10], [ 1, 13]], # i =0 [[ 0, 11], [ 1, 12]], # i =1 ] But actually after understanding what zip does, I think I don't need it anyway... Talking about this: can you give me an example of another use of zip ? not just zip(*head) I did help(zip) but I could partially understand what it does. I learned more by doing: x,y,z = zip(*head) and then printing x,y,z individually. Thanks for your help so far. Oz

 [Matplotlib-users] plotting scattered data from array From: Oz Nahum - 2008-09-20 09:14:09 I'm trying again to understand how to plot scattered data from array into contour graph. I looked at http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data and I understand I have to grid my data. However, in most samples the plot is of a function. Let's say I want to plot some geological data, suppose water table head, and I have the following 3D aray x y head head = ((0, 0, 10), (1, 0, 13), (2, 0, 11), (3, 0, 12), (1, 2, 11)) matplotlib has lot's of restrictions about how I can plot and interpolate the data, which causes a lot of confusion in my side... I'll be happy if someone could supply me a clue of how to plot contours of data which comes in arrays or raster format and not an equation. Thanks, Oz
 Re: [Matplotlib-users] plotting scattered data from array From: Goyo - 2008-09-20 12:19:25 Try something like this: import pylab as pl head = ((0, 0, 10), (1, 0, 13), (2, 0, 11), (3, 0, 12), (1, 2, 11)) x, y, z = zip(*head) xi, yi = pl.arange(0, 4, 0.1), pl.arange(0, 3, 0.1) g = pl.griddata(x, y, z, xi, yi) pl.scatter(x, y) pl.contour(xi, yi, g) Level values are automatically chosen in this example but you can provide the number of values or a sequence of them. Note that no extrapolation is done outside convex hull defined by input data. Goyo El sáb, 20-09-2008 a las 11:13 +0200, Oz Nahum escribió: > I'm trying again to understand how to plot scattered data from array into > contour graph. > I looked at > http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data > and I understand I have to grid my data. However, in most samples the plot > is of a function. > Let's say I want to plot some geological data, suppose water table head, and > I have the following 3D aray > x y head > head = ((0, 0, 10), > (1, 0, 13), > (2, 0, 11), > (3, 0, 12), > (1, 2, 11)) > matplotlib has lot's of restrictions about how I can plot and interpolate > the data, which causes a lot of confusion in my side... > I'll be happy if someone could supply me a clue of how to plot contours of > data which comes in arrays or raster format and not an equation. > Thanks, > Oz > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users