Plot2D TCL UTILITIES USER MANUAL Plot2D
SYNOPSIS
Produce X vs Y plots
PACKAGE
TCLPLT
NAME
Plot2D
USAGE
Plot2D  pID xA yA X Y BeG EnD FmT pOpsY {pOpsX}
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
Y - The array of Y values
BeG - Array index at which to begin the plot
EnD - Array index at which to end the plot
FmT - The output plot format which is either LINE, SCATTER, or HISTOGRAM.
pOpsY - A list of plot options which are applied to the Y data array. The complete list of parameters is given in the procedure description below.
pOpsX - An optional list of plot options which are applied to the X data array. The complete list of parameters is given in the procedure description below.
RETURN DEFINITION
None
DESCRIPTION
Plot2D puts up plot of X vs Y in pID. The plot can be drawn against any combination of X Y axes (Xb or Xt and Yb or Yt). The plot begin at the data index BeG in the arrays and end at index EnD. The plot can be output either as a LINEline plot, a SCATTER plot or as a HISTOGRAM plot.
The procedure has multiple options which are used when outputting the line plots. These are separated into options which are applied to the Y array of data pOpsY and options which are applied to the X array of data pOpsX. A complete listing of both sets of options is given in the table below.
LIST INDEX DEFAULT DESCRIPTION
pOpsY 0 255 Index into the color table to the color used when outputting the plot.
pOpsY 1 NONE Data exclusion condition used to filter the Y data set when plotting. This can be NONE for no filtering, or <=, <, >, >=, == to filter. The filtering is done as
Y "Filter Condition" V
where V is the filter value given in the next list element. When Y does not meet the condition statement it is dropped from the plot.
pOpsY 2 Filter value. This is ignored if the filter condition is NONE, otherwise it is the value used in the comparison with the data.
pOpsY 3 HOLD This element in the list is used unless when the plot format is SCATTER. It should be set to BiTMaP if the symbol used in the scatter plot comes from a bitmap file, otherwise it is the font to use for the ASCII symbol to be output. To keep the currently set font set this to HOLD.
pOpsY 4 10 Scatter symbol size. This is only used if plot format is SCATTER and the plot symbol is not a bitmap.
pOpsY 5 The scatter symbol. If the scatter symbol to use is defined as a bitmap this can either be an index into one of the TclGPH defined bitmap symbols (see BitMap) or the name of the file containing the bitmap, otherwise it should be the ASCII string to be output.
pOpsX 0 NONE Data exclusion condition used to filter the X data set when plotting. This can be NONE for no filtering, or <=, <, >, >=, == to filter. The filtering is done as
X "Filter Condition" V
where V is the filter value given in the next list element. When X does not meet the condition statement it is dropped from the plot.
pOpsX 1 Filter value. This is ignored if the filter condition is NONE, otherwise it is the value used in the comparison with the data.
As of yet the procedure does not support the labeling of the contour levels. Also the transformation from value to color has the same scaling (linear or log) as is set for the scaling of the contour levels in LSCA.
ERRORS
None Generated
C BACKING
No
EXAMPLE(S)
EXAMPLE 1: Examples of different plots.
# SET up a fine and coarse synthetic data set solving the equation 
#
#      y = 4.0 - 2.0x + 0.5x*x - 0.7x*x*x
#
# 

set nP 0
for { set I -5.0 } { $I <= 5.0 } { set I [expr $I + 0.1] } { 
   set X($nP) $I
   set Y($nP) [expr 4.0 - 2.0 * $I + 0.5 * $I * $I -0.7 * $I * $I * $I]  
   incr nP
}

set nPa 0
for { set I -5.0 } { $I <= 5.0 } { set I [expr $I + 1.0] } { 
   set Xa($nPa) $I
   set Ya($nPa) [expr 4.0 - 2.0 * $I + 0.5 * $I * $I -0.7 * $I * $I * $I]  
   incr nPa
}

# SET up a fine and coarse synthetic data set solving the equation 
#      y = cos(x) - sin(2x) + cos**2(3x)

set nPb 0
for { set I 0.0 } { $I <= 360.0 } { set I [expr $I + 1.0] } { 
   set A [expr $I / $RtoD]
   set cV [expr cos(3 * $A)]
   set Xb($nPb) $I
   set Yb($nPb) [expr cos($A) - sin(2 * $A) + $cV * $cV]
   incr nPb
}

# SET a window size

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

# OPEN graphics
 
GraphicsOn TK RainBow 

# DEFINE the plot window and assign the plot number

GenWindow 1 0.15 0.15 0.0 0.85 0.85 0.0  -5. -2.0 0. 5.0 4.0 0.
DefinePlot 1 1 -1 -1

# SCALE the secondary axis

SetAxis 1 SECONDARY 0.0 0.0 HOLD 360.0 1.0 HOLD HOLD HOLD HOLD

# AUTOSCALE the primary Y axis to the polynomial function

AutoScale 1 Yb Y $nP 

# AUTOSCALE the secondary Y axis to the trig function

AutoScale 1 Yt Yb $nPb 

# PLOT the coarse polynomial data as a purple histogram

set GoP [list $GphInfo(Purple)]
Plot2D 1 Xb Yb Xa Ya 0 [expr $nPa -1] HISTOGRAM $GoP 

# OVERLAY the coarse polynomial data as a scatter plot of red +'s

set GoP [list $GphInfo(Red) <= -1.0e8 BiTMaP 16 1]
Plot2D 1 Xb Yb Xa Ya 0 [expr $nPa -1] SCATTER $GoP 

# OVERLAY the fine polynomial data set as a white line plot

set GoP [list $GphInfo(White) NONE]
Plot2D 1 Xb Yb X Y 0 [expr $nP -1] LINE $GoP 

# OVERLAY the trig data set as a cyan line plot.  Plot it against the
#    secondary axis

set GoP [list $GphInfo(Cyan) NONE]
Plot2D 1 Xt Yt Xb Yb 0 [expr $nPb -1] LINE $GoP 

# ANNOTATE the plot.  Only need 6 major tick marks along Xt

PLTinfoChg 1 Xt TICKS MJNUMBER 6
PlotOutlines 1 [list "X" 1.0 "Y" 1.0] [list BOTH BOTH BOTH BOTH]

      
Apr 7, 2007