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
- -xt XTICS --- X-axis tics
- -yt YTICS --- Y-axis tics
- -x2t X2TICS --- X2-axis tics
- -y2t Y2TICS --- Y2-axis tics
- -mx MXTICS --- frequency of minor tics marks for X axis
- -my MYTICS --- frequency of minor tics marks for Y axis
- -mx2 MX2TICS --- frequency of minor tics marks for X2 axis
- -my2 MY2TICS --- frequency of minor tics marks for Y2 axis
- -xl XLABEL --- label for X axis
- -yl YLABEL --- label for Y axis
- -x2l X2LABEL --- label for X2 axis
- -y2l Y2LABEL --- label for Y2 axis
- -xr XRANGE --- X-axis range specified as MIN:MAX (where MIN and MAX are numbers)
- -yr YRANGE --- Y-axis range specified as MIN:MAX
- -x2r X2RANGE --- X2-axis range specified as MIN:MAX
- -y2r Y2RANGE --- Y2-axis range specified as MIN:MAX
- -xf XFORMAT --- format for the X-axis numbers (in C syntax)
- -yf YFORMAT --- format for the Y-axis numbers
- -x2f X2FORMAT --- format for the X2-axis numbers
- -y2f Y2FORMAT --- format for the Y2-axis numbers
- -tm TOP_MARGIN --- top margin specs (aka Gnuplot's tmargin)
- -bm BOTTOM_MARGIN --- bottom margin (aka bmargin)
- -lm LEFT_MARGIN --- left margin (aka lmargin)
- -rm RIGHT_MARGIN --- right margin (aka rmargin)
- -key KEY --- key (or legend) containing a title for each plot in the graph
- -grid GRID --- grid, e.g., -grid {lt -1 dt (5,1,2,1)}
- -title TITLE --- title, e.g., -title {'This is title' font 'Arial,12'}
- -u USING --- Gnuplot's "using" plot specs
- -w WITH --- Gnuplot's "with" plot specs
- -x EXTRA --- extra Gnuplot commands/configuration, e.g., -x {set title 'simple band structure'}
- -out ROOTNAME --- rootname for the Gnuplot-script and, for file terminals, the output image file
- -t TERMINAL --- terminal to plot to; possible terminals are those returned by ::pwtk::gp::pwtk_terminals (file-terminals: eps, pdf, svg, png; window-terminals: win, qt, wxt, x11).
- -s PX,PY --- terminal size in pixels (default = 1200,800); ignored for EPS
- -v --- visualize the generated plot file (for file terminals)
ARGUMENTS
- DATAFN1 --- the 1st datafile or function to plot
- DATAFN2 --- the 2nd datafile or function to plot
- ...
RETURN VALUE
- the name of the created image (for file terminals)
- an empty string (for non-file terminals)
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] }