From: Eric F. <ef...@ha...> - 2006-04-30 18:48:22
|
Michael V. De Palatis wrote: > On Sat, Apr 29, 2006 at 08:41:48AM -1000, Eric Firing wrote: > >>How easy it is to do this depends on your ascii file format, and how the >>data are organized in it. Are the points in order? e.g. >> >>x0, y0, z00 >>x0, y1, z01 >>x0, y2, z02 >>x1, y0, z10 >>x1, y1, z11 >>x1, y2, z12 > > > This is precisely the ordering. > > >>Are the values space-delimited, or comma-delimited, or in some other >>format? > > > The values are space-delimited. The way I am reading them in is with > readline, then splitting the resulting string and appending to a list > of x, y, and z values. > > >>Is the grid uniform in the sense that all the x-intervals are the same >>and all the y-intervals are the same? > > > Unfortunately, the grid is not uniform. From the responses I have been > getting thus far, it's looking like this is going to be far more > complicated than I had hoped... It might not be complicated, but forget about using imshow--it is for image data, which are inherently evenly spaced. Pcolor and pcolormesh don't have this limitation. Note that Zij will give the color of the box with diagonal corners (Xij, Yij) and (Xi+1,j+1, Yi+1,j+1), so if Z has the same dimensions as X and Y, the last row and column will not be shown. If your input data are intended to give the (x,y) positions of the centers of regions rather than the corners, then you will need to do some sort of regridding of Z, or shifting of your X and Y points, in order to get everything exactly right with pcolor and pcolormesh. The attached script and sample data file show how you can put the data from your ascii file into X, Y, and Z arrays, and plot them using pcolor or pcolormesh. This is for the simple case in which treating x and y as corners is good enough. Note that the grid does not have to form rectangular cells; they can be quadrilaterals. I illustrated this in the sample file by shifting one point. Eric |