TABLE OF CONTENTS


::pwtk::multiplot

SYNOPSIS

proc ::pwtk::multiplot {args} {

USAGE

    ::pwtk::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

ARGUMENTS

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.

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 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

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
}