[Thread Prev][Thread Next][Index]

Re: How to shade and interpolate a scattered data file ?



Hi everyone,
There's also the "go polymark" script, which lets you plot a set
of polygons with a few short commands.

yes? go/help polymark    !  See what the polymark arguments are.

yes? file/form=free/var=lon,depth,value   file.dat
yes? !  Plot the lon, depth locations; this sets up the plot scaling for polymark script.
yes? plot/vs lon, depth

yes? go polymark   poly, lon, depth, value, square

Ansley Manke

Mick Spillane wrote:

> Hello Ding Chi,
>
> You are right in thinking that shade (also fill and contour) apply to
> data that are 2-D with an underlying grid.  The command "define axis"
> is used to define the grid axes, not the plotting region.  If your data
> are 2-D but scattered, you might try the "polygon" command if you want
> to avoid interpolating the scattered points to a grid.  Here is a simple
> example where I generate random x-z locations and define the value to
> be represented as an algebraic function. At each point a rectangular
> box is filled with a color that represents the value.  The size of the
> boxes is controlled by the values dx and dz
>
> region/i=1:1000 ! 1000 data triplets lon,depth,value
> ! define the data triplets
> let xx=i
> let/title="Longitude" lon=10*randn(xx)
> let/title="Depth" depth=(-50)*randu(xx)
> let value=cos(0.01745*lon)*exp(depth/10)
> ! and the corners of the box centered on each data point
> let dx=0.5 ; let bx=ysequence({`(-1)*dx`,`dx`,`dx`,`(-1)*dx`})
> let dz=0.5 ; let bz=ysequence({`dz`,`dz`,`(-1)*dz`,`(-1)*dz`})
> ! then use "polygon" to show the data structure without interpolation
> polygon bx+lon,bz+depth,value
>
> Hope this helps.  In your case you would read in the data triplets with
> something like
> file/form=free/var=lon,depth,value your.file
> let dx=... ; let bx=ysequence({`(-1)*dx`,`dx`,`dx`,`(-1)*dx`})
> let dz=... ; let bz=ysequence({`dz`,`dz`,`(-1)*dz`,`(-1)*dz`})
> ! where dx and dz are values that make suitable sized boxes for your case
> polygon bx+lon,bz+depth,value
>
> One slight change you might need is if your depth values are all positive
> (say in the range 0 to 50) and you want the deepest values at the bottom
> of the plot.  Then you would use something like
>
> polygon/vlimits=50:0:-10 bx+lon,bz+depth,value
>
> Good luck,
> Mick
>
> |____spillane@pmel.noaa.gov____|
> |__Room 2070 Bldg#3 NOAA/PMEL__|
> |____Phone_:_(206)526-6780_____|

--
Ansley Manke  Pacific Marine Environmental Laboratory  Seattle WA  (206)526-6246




[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement