TABLE OF CONTENTS
::pwtk::multiplot
SYNOPSIS
proc ::pwtk::multiplot {args} {
USAGE
multiplot ?OPTIONS? DATAFN_LIST1 ?DATAFN_LIST2? ... where DATAFN_LIST1, DATAFN_LIST2... are a list of datafiles and/or functions to plot, and OPTIONS are: -xl XLABEL -yl YLABEL -xr XRANGE -yr YRANGE -xf XFORMAT -yf YFORMAT -u USING -w WITH -e EXTRA -t TERMINAL -v
OPTIONS
- -xl XLABEL --- X-axis label
- -yl YLABEL --- Y-axis label
- -xr XRANGE --- X-axis range specified as XMIN:XMAX or {XMIN:XMAX} or "XMIN:XMAX"
- -yr YRANGE --- Y-axis range specified as YMIN:YMAX or {YMIN:YMAX} or "YMIN:YMAX"
- -xf XFORMAT --- format for X-axis (e.g. %.2f)
- -yf YFORMAT --- format for Y-axis (e.g. %.2f)
- -u USING --- Gnuplot's "using" plot specification
- -w WITH --- Gnuplot's "with" plot specification
- -e EXTRA --- extra Gnuplot commands/configuration, e.g., -e {set nokey; set title 'simple multiplot'}
- -t TERMINAL --- terminal for the plot
- -v --- visualize the generated image(s) (for file terminals)
ARGUMENTS
- DATAFN_LIST1 --- list of datafiles and/or functions to plot in the 1st plot
- DATAFN_LIST2 --- list of datafiles and/or functions to plot in the 2nd plot
- ...
PURPOSE
"multiplot" plots data as the multiplot. Each list of data (DATAFN_LIST) is plotted in a separate plot, i.e., DATAFN_LIST1 in plot-1, DATAFN_LIST2 in plot-2, etc. This is meant as a fast way of plotting multi-plots. For a more elaborate and configurable multi-plotting, use the ::pwtk::gp::multiplot object-oriented interface instead.
EXAMPLE
scanpar k [seq 2 2 8] { scanpar ecut [seq 10 4 30] { set head scf.k$k.ecut$ecut SYSTEM "ecutwfc = $ecut" K_POINTS (automatic) "$k $k $k 1 1 1" runPW $head write k.$k.dat [pwo_totene $head.out] } } # plot each datafile separately and also all of them together multiplot -xl "ecutwfc (Ry)" -yl "Total energy (Ry)" -u 2:3 \ k.2.dat k.4.dat k.6.dat k.8.dat { k.2.dat k.4.dat k.6.dat k.8.dat }
RETURN VALUE
- a list of created images (for file terminals)
- an empty string (for non-file terminals)
SOURCE
variable write_fid variable multiplot_id # parse args plot_parseOpt_ ifnotempty opt(u) { set opt(u) "u $opt(u)" } #ifnotempty opt(w) { set opt(w) "w $opt(w)" } ifset opt(xl) '' ifset opt(yl) '' # plot finish [concat {*}$args] set nplot 0 foreach datafnList $args { foreach datafn $datafnList { if { [file exists $datafn] } { # datafn is a file set width [expr { $opt(w) eq {} ? $::pwtk::gp::gp(datafile_with) : "w $opt(w)" }] append plot($nplot) "[squote $datafn] $opt(u) $width, " } else { # datafn is a function, skip $opt(u) set width [expr { $opt(w) eq {} ? $::pwtk::gp::gp(function_with) : "w $opt(w)" }] append plot($nplot) "$datafn $width, " } } set plot($nplot) [string trim $plot($nplot) {, }] incr nplot } set id [incr ::pwtk::gp::multiplot_id] set gp [::pwtk::gp::multiplot new -o landscape auto $nplot multiplot-$id.$opt(t)] $gp options [list xlabel [squote $opt(xl)] ylabel [squote $opt(yl)]] ifnotempty opt(xr) { $gp options [list xrange [rangequote $opt(xr)]] } ifnotempty opt(yr) { $gp options [list yrange [rangequote $opt(yr)]] } ifnotempty opt(xf) { $gp options [list format.x [squote $opt(xf)]] } ifnotempty opt(yf) { $gp options [list format.y [squote $opt(yf)]] } ifnotempty opt(e) { $gp add $opt(e) } for {set i 0} {$i < $nplot} {incr i} { $gp plot $plot($i) } $gp exec set outputs [$gp outputs] $gp destroy displayPlots_ $opt(v) $opt(t) $outputs return $outputs }