Plot3D TCL UTILITIES USER MANUAL Plot3D
SYNOPSIS
Produce 3D plots using color for intensity
PACKAGE
TCLPLT
NAME
Plot3D
USAGE
Plot3D  pID xA yA X Y Z FmT pOps cM
INPUT DEFINITIONS
pID - The plot identifier in which the plot is output. This was set in a call to DefinePlot.
xA - The X axis to use in outputting the plot. This is either Xb or Xt.
yA - The Y axis to use in outputting the plot. This is either Yb or Yt.
X - The array of X values. This can be an undefined variable if FmT is AUTO.
Y - The array of Y values. This can be an undefined variable if FmT is AUTO.
Z - The array of Z or intensity values
FmT - Processing format which can be either AUTO or MANUAL. With AUTO both the X and Y inputs are ignored and generated internally. With MANUAL the grid locations are derived from the X and Y input arrays.
pOps - An array of input parameters. The complete list of parameters is given in the procedure description below.
cM - The color map which is generated either in a call to ColorBar or PLTcolorMap.
RETURN DEFINITION
None
DESCRIPTION
Plot3D produces a 3D plot of the data (X, Y, Z). The intensity data contained in Z is represented by color in the plot. The Z data must be an nXxnY grid of data which is laid in a 1D array either row by row or column by column. Gererally the grid was formed through a call to TUdataGrid.
Plot3D can be invoked either in AUTO or MANUAL mode. AUTO mode can be used whenever the intensity grid was created using TUdataGrid. In this case both X and Y are ignored in the procedure and the DefinePlot should be invoked as:
DefinePlot $pID $wID $gI(4) $gI(5)
where pID is the plot identifier, wID is the window identifier and gI is the grid information array used to defined the intensity grid. The grid storage format and dimensionality is supplied to the routine in pOps.
MANUAL mode allows for grids in which cells and/or column have different widths (dX) and heights (dY), with the restriction that a column of cells all have the same dX and a row of cells all have the same dY. When invoking in MANUAL mode X and Y are arrays of the X and Y matix cell edge postions respectively. Since it is assumed at all cells in a given matix column have the same X edges and that the cells in a given grid row have the same Y edges, the X and Y arrays need only define the edges in the first row and first column respectively. X is then dimensioned nX+1 and Y is dimensioned nY+1. The grid storage format and dimensionality is supplied to the routine in pOps.
The grid storage format and when needed the grid dimensions are supplied to the procedure in the array pOps. A complete listing of array elements is given in the table below.
INDEX DEFAULT DESCRIPTION
RC COLUMN The Z grid storage format. This is either COLUMN or ROW. If the grid was formed in a call to TUdataGrid set to gI(8) where gI is the grid information used in creating the grid.
NX The number of columns in the Z grid. For a grid formed in a call to TUdataGrid set to gI(4) where gI is the grid information used in creating the grid. This array element is unused in AUTO mode.
NY The number of rows in the Z grid. For a grid formed in a call to TUdataGrid set to gI(5) where gI is the grid information used in creating the grid. This array element is unused in AUTO mode.
UF The update frequency at which to display the plot being drawn. The default value is 100000. The value indicates how many row or columns of data are drawn before the screen is updated. The value must be greater than 0.
The mapping of the values in Z to color are given in the array cM. This array should be obtained either from a call to ColorBar or PLTcolorMap.
ERRORS
None Generated
C BACKING
No
EXAMPLE(S)
EXAMPLE 1: Examples of a 3D plot called in both AUTO and MANUAL mode.
# SET up an array of data consisting of 2 displaced gaussians 

set nP 0
for { set X -6.0 } { $X <= 6.0 } { set X [expr $X + .1] } {
   for { set Y -6.0 } { $Y <= 6.0 } { set Y [expr $Y + .1] } {
       set Xx($nP) $X
       set Yy($nP) $Y
       set Ra [expr $X * $X + $Y * $Y]
       set Rb [expr ($X - 2) * ($X - 2) + ($Y - 2) * ($Y - 2)]
       set Vv($nP) [expr exp (-$Ra / 6.0) + exp (-$Rb / 2.0)]
       incr nP
   }
}

# SET up the grid information array.  This defined a matix of 100x100 grids
#   with a range from (-6,-6) to (6,6)

set gInfo(0) -6.0
set gInfo(1) 6.0
set gInfo(2) -6.0
set gInfo(3) 6.0
set gInfo(4) 100
set gInfo(5) 100
set gInfo(6) POINT
set gInfo(7) POINT
set gInfo(8) COLUMN
set gInfo(9) IGNORE
set gInfo(10) NEW:ADD:END
set gInfo(11) -1
set gInfo(12) -5
set gInfo(13) -1.0e30
set gInfo(14)  1.0e30
set gInfo(15)  NO
set gInfo(16)  NO

# GRID the data

TUdataGrid $nP 1 Xx Xx 1 Yy Yy Vv Grid Norm gInfo

# SET a window size

set GphInfo(xsScrL) 600
set GphInfo(ysScrL) 500
set GphInfo(xScrL) 600
set GphInfo(yScrL) 500

# Turn on graphics with a RainBow colorbar, background will be black 

GraphicsOn TK RainBow 

# DEFINE a window covering the entire canvas.  We'll output a colorbar
#   in this window.

GenWindow 0 0.0 0.0 0. 1.0 1.0 0.0  0. 0. 0. 1. 1. 0.

# DEFINE a pair square window and assign plot numbers to them.  The first
#   will hold an AUTO generated plot and the second a MANUAL generate
#   plot. NOTE difference in AUTO and MANUAL plot DefinePlot calls.

SqWindow 1 0.10 0.10 0. 0.4 -6. -6. 0. 6. 6. 0.
DefinePlot 1 1 $gInfo(4) $gInfo(5)

SqWindow 2 0.5 0.5 0. 0.4 -6. -6. 0. 6. 6. 0.
DefinePlot 2 2 -1 -1 

# SET some common options to use in generating a colorbar. Well linear
#   scale the PRIMARY and LOG scale the secondary

set cInfo(pMIN) 0.0
set cInfo(pMAX) 1.5
set cInfo(pSCA) LINEAR
set cInfo(sMIN) 0.01
set cInfo(sMAX) 1.5
set cInfo(sSCA) LOG
set cInfo(FMT)  RHORIZONTAL
set cInfo(PFMTS) HOLD:HOLD:%.1f
set cInfo(SFMTS) HOLD:HOLD:expon
set cInfo(PNUMS) 5:5
set cInfo(LABELS) AUTO:MANUAL
set cInfo(PSIZE) HOLD:HOLD:10:10
set cInfo(SSIZE) HOLD:HOLD:10:10

# PUT up the colorbar

ColorBar 0 .55 0.2 0.0 .90 0.25 0.0 cInfo cMa cMb

# PUT up an AUTO 3D generated plot in the lower left had plot.  Don't 
#   need X, Y or pOps arrays.  Don't need last since defaults are right 
#   for this case

Plot3D 1 Xb Yb Dummy Dummy Grid AUTO Dummy cMa

# LETS overlay a set of contours on the plot

set cOps(CFMT) MONOCHROMATIC
set cOps(CLEV) AUTO
set cOps(LMIN) 0.0
set cOps(LMAX) 1.2
set cOps(LSCA) LINEAR
set cOps(NLEV) 10
set cOps(CMIN) 0.0
set cOps(CMAX) 1.2
set cOps(CCOL) $GphInfo(White)

Contour 1 Grid gInfo cOps

# PUT up a MANUAL 3D generated plot using the same data grid as above.  Need
#  to define the pOps array

set pOps(RC) $gInfo(8)
set pOps(NX) $gInfo(4)
set pOps(NY) $gInfo(5)

# ESTABLISH the X and Y arrays of the cell edges

TUgridInfo 30 gInfo Xe
TUgridInfo 31 gInfo Ye

# PUT up the plot in the upper right-hand plot but use the LOG color mapping

Plot3D 2 Xb Yb Xe Ye Grid MANUAL pOps cMb

# ADD the contours 

Contour 2 Grid gInfo cOps

# Outline and annotate both plots 

PlotOutlines 1 [list "" 1.0 "" 1.0] [list BOT BOT BOTH BOTH]
PlotOutlines 2 [list "" 1.0 "" 1.0] [list BOT BOT BOTH BOTH]
      
Apr 7, 2007