TABLE OF CONTENTS


::pwtk::plot

SYNOPSIS

proc ::pwtk::plot {args} {    

USAGE

   ::pwtk::plot ?PLOTTING-OPTIONS?  DATAFN1  ?DATAFN2? ...

   where DATAFN1, DATAFN2, ... are either datafiles or functions to plot.

   PLOTTING-OPTIONS are:

     -xt  XTICS 
     -yt  YTICS 
     -x2t X2TICS 
     -y2t Y2TICS 
      
     -mx  MXTICS 
     -my  MYTICS 
     -mx2 MX2TICS 
     -my2 MY2TICS 
      
     -xl  XLABEL 
     -yl  YLABEL 
     -x2l X2LABEL 
     -y2l Y2LABEL 
      
     -xr  XRANGE 
     -yr  YRANGE 
     -x2r X2RANGE 
     -y2r Y2RANGE 
      
     -xf  XFORMAT 
     -yf  YFORMAT 
     -x2f X2FORMAT 
     -y2f Y2FORMAT 
      
     -tm TOP_MARGIN 
     -bm BOTTOM_MARGIN 
     -lm LEFT_MARGIN 
     -rm RIGHT_MARGIN 

     -key   KEY
     -grid  GRID
     -title TITLE

     -u USING 
     -w WITH 
     -x EXTRA 
      
     -out ROOTNAME
     -t   TERMINAL
     -s   PX,PY
     -v 

   A more detailed description of PLOTTING-OPTIONS and ARGUMENTS is provided below.

PURPOSE

::pwtk::plot plots data from one or more datafiles or functions on the same plot. If the datafiles were created with the ::pwtk::write command, they are closed prior to being plotted.

This is meant as a fast way of plotting simple data. For a more elaborate and configurable plotting, use the ::pwtk::gp::plot object-oriented interface instead.

For an example, see the example in ::pwtk::scanpar.

PLOTTING OPTIONS

ARGUMENTS

RETURN VALUE

SOURCE

    variable write_fid
    
    # parse args
    set arguments "DATAFN1  ?DATAFN2? ..."
    plotParseOpt_
        
    ifnotempty opt(u) { set opt(u) "u $opt(u)" }
    ifset opt(xl) ''
    ifset opt(yl) ''
    
    # plot's name

    if { $opt(out) ne {} } {
        set head [headname $opt(out) .$opt(t)]
    } else {
        if { [llength $args] == 1 && [file exists $args] } {
            set head plot-[file tail [file rootname $args]]
        } else {
            set id [incr ::pwtk::gp::plot_id]
            set head plot-$id
        }
    }

    # plot
    
    finish $args
    
    foreach datafn $args {
        if { [file exists $datafn] } {
            # datafn is a file
            set with [expr { $opt(w) eq {} ? $::pwtk::gp::gp(datafile_with) : $opt(w) }]
            append plot "[squote $datafn] $opt(u) w $with, "
        } else {
            # datafn is a function, skip $opt(u)
            set with [expr { $opt(w) eq {} ? $::pwtk::gp::gp(function_with) : $opt(w) }]
            append plot "$datafn w $with, "
        }
    }
    set plot [string trim $plot {, }]

    set gp [::pwtk::gp::plot new -s $opt(s) $head.$opt(t)]
    $gp cmdlineOpts opt    
    $gp plot $plot

    return [::pwtk::gp::execDisplay_ $gp opt]
}