TABLE OF CONTENTS


multiplot::constructor

SYNOPSIS

    constructor {args} {

PURPOSE

Create a new Gnuplot multi-plot object.

HOW TO USE

Either:

    set obj [::pwtk::gp::multiplot new ?OPTIONS? auto NPLOTS ?NPMAX? ?NX?  ?HEAD.TERM?]

or:

    set obj [::pwtk::gp::multiplot new ?OPTIONS? manual PP NX NY  ?HEAD.TERM?]

where OPTIONS are:

    -o  ORIENT
    -s  SX,SY 
    -fs FONTSIZE
    -t  TITLE    
    -spin       
    -pause PAUSE        

ARGUMENTS

OPTIONS

DESCRIPTION

Two modes of multiplot Gnuplot objects are possible:

The auto mode: PWTK determines how to arrange plots on the page, i.e., number of plots in X- and Y-directions (columns and rows). The nplots, npmax, and nx are:

The manual mode: User manually specifies the layout by specifying pp, nx, ny, where:

SOURCE

        set options_initiated 0
        array set my_options [array get ::pwtk::gp::options]
        
        set page 0
        set plot 0
                
        # command-line arguments usage:
        #      ?OPTIONS? auto   NPLOTS ?NPMAX? ?NX?  ?HEAD.TERM?
        #      ?OPTIONS? manual PP NX NY  ?HEAD.TERM?

        set nargmin 2
        set nargmax 5
        set usage "new ?-o ORIENT?  ?-s SIZE?  ?-fs FONTSIZE?  ?-t TITLE?  ?-spin?  {auto NPLOTS ?NPMAX? ?NX? | manual PP NX NY}  ?HEAD.TERM?"
        ::pwtk::gp::parseOpt_term_

        set mode [lindex $args 0]
        
        switch -- $mode {
            auto {
                # args == auto NPLOTS ?NPMAX? ?NX? ?HEAD.TERM?
                #
                # where: NPMAX = (optional) max # plots per page, overwrites default
                #        NX    = (optional) max # of plots in X-dir, overwrites default

                set nplot   [lindex $args 1]
                set lastarg [lindex $args end]
                
                if { ! [string is integer -strict $lastarg] } {
                    set head_dot_term $lastarg
                    set args [lrange $args 0 end-1]
                } else {
                    set id [incr ::pwtk::gp::multiplot_id]
                    set head_dot_term multiplot-$id.win
                }
                set orient [::pwtk::gp::orient [::pwtk::gp::term_ $head_dot_term] $opt(s) $opt(t)]

                set len   [llength $args]
                set npmax [expr { $len >= 3 ? [lindex $args 2] : -1 }]
                set nx    [expr { $len == 4 ? [lindex $args 3] : -1 }]

                if { ! [::pwtk::type::number posint -strict $nplot] } {
                    ::pwtk::error "NPLOT must be positive integer, but got $nplot" 1
                }
                if { ! [string is integer -strict $npmax] || ! [string is integer -strict $nx] } {
                    ::pwtk::error "NPMAX and NX must be integers, but got $npmax and $nx" 1
                }
                array set mp [::pwtk::gp::multiplot_array $nplot $npmax $nx $orient $opt(spin)]
            }
            
            manual {                
                # args == manual PP NX NY  ?HEAD.TERM?
                
                set pp [lindex $args 1]
                set nx [lindex $args 2]
                set ny [lindex $args 3]
                set lastarg [lindex $args 4]
                
                if { $lastarg ne {} } {
                    set head_dot_term $lastarg
                    set args [lrange $args 0 end-1]
                } else {
                    set id [incr ::pwtk::gp::multiplot_id]
                    set head_dot_term multiplot-$id.win
                }

                if { ! [::pwtk::type::number posint -strict $pp] \
                         || ! [::pwtk::type::number posint -strict $nx] \
                         || ! [::pwtk::type::number posint -strict $ny] } {
                    ::pwtk::error "PP, NX, NY must be positive integers, but got: \"$args\"" 1
                }
                array set mp [subst {
                    pp $pp
                    np [expr $nx*$ny]
                    nx $nx
                    ny $ny}]
                set mp(fsize) $opt(fs)
            }
            
            default {
                ::pwtk::error "unkown mode \"$mode\", must be either auto or manual" 1
            }
        }

        set head [::pwtk::gp::head_ $head_dot_term]
        set term [::pwtk::gp::term_ $head_dot_term]
        
        # -s
        
        if { $opt(s) == {} } {
            switch -- [::pwtk::gp::gp2pwtk $term] {
                eps { set size $::pwtk::gp::gp(eps.multisize) }
                pdf { set size $::pwtk::gp::gp(pdf.multisize) }
                default { set size $::pwtk::gp::gp(multisize) }
            }
        } else {
            set size $opt(s)
        }

        # -fs
        
        if { $opt(fs) == {} } {
            set fsize $mp(fsize)
        } else {
            set fsize $opt(fs)
        }

        # -spin & -p

        set opts {}
        if { $mp(pp) > 1 } {
            append opts "-p "
        }
        if { $opt(spin) } {
            append opts "-spin "
        }

        # -pause
        
        my pause_ mouse $opt(pause)

        # -t
        
        if { $opt(t) == {} } {
            if { $term in $::pwtk::gp::gp(win.terminals) } {
                if { $mp(pp) == 1 } {
                    set next "($pauseText to Exit)"
                } else {
                    set next "($pauseText to continue to next page)"
                }        
                set title "Page 1/$mp(pp)  $next"
            } else {
                set title {}
            }        
        } else {
            set title "title '[string trim $opt(t) ']'"
        }

        set prolog [::pwtk::gp::get_term {*}$opts -o $opt(o) -s $size -fs $fsize -t $title $head_dot_term]\n
    }