TABLE OF CONTENTS


splot::constructor

SYNOPSIS

    constructor {args} {

PURPOSE

Create a new Gnuplot 'splot' object.

HOW TO USE

Splot Gnuplot object is created as:

   set obj [pwtk::gp::splot new ?OPTIONS?  ?HEAD.TERM?]

where options specific for 3D surface and/or heatmap plots are:

   -type TYPE
   -pal PALETTE
   -nocontour
   -cc CONTOUR_COLOR

while general options are:

   -o ORIENT
   -s SIZE
   -fs FONTSIZE
   -t TITLE
   -p
   -pause PAUSE

ARGUMENTS

OPTIONS

Options specific for 3D surface and/or heatmap plots:

General options:

Here are the PWTK's predefined color palettes and their names that can be accessed with the -pal option. To invert a palette, use "-pal {PALETTE negative}", where PALETTE is one of:

Note that for PALETTE only a substring that uniquely identifies it is required. For example, "-pal pa" selects the "pale-rainbow" palette.

RETURN VALUE

The Gnuplot 'splot' object.

SOURCE

        set options_initiated 0
        set page 1; # N.B. page must be 1 for new_page to work correctly

        set argsOrig $args
        set nargmin 0
        set nargmax 1
        set usage "new  ?-type TYPE?  ?-pal PALETTE?  ?-nocontour?  ?-cc CONTOUR_COLOR?  ?-o ORIENT?  ?-s SIZE?  ?-fs FONTSIZE?  ?-t TITLE?  ?-p?  ?HEAD.TERM?"
        
        ::pwtk::gp::parseOpt_term_

        # TYPE option
        
        switch -glob -- $opt(type) {
            b* - s*m* {
                # both | surfmap
                array set my_options [array get ::pwtk::gp::surfmapOptions]
            }
            s* {
                # surface
                array set my_options [array get ::pwtk::gp::surfOptions]
            }
            h* - m* {
                # heatmap | map
                set map 1
                array set my_options [array get ::pwtk::gp::mapOptions]
            }
            default {
                ::pwtk::error "uknown splot type \"$opt(type)\", must be one of map, surface, or both" 1
            }
        }

        # -pal PALETTE
        #
        # N.B. the value of PALETTE is of form {PALETTE_NAME ?DIRECTION?},
        # where DIRECTION is optional and can be either "positive" or "negative"

        lassign $opt(pal) paletteName dir
        ::pwtk::ifset dir positive
        switch -glob -- $dir {
            p* { set dir positive }
            n* { set dir negative }
            default {
                ::pwtk::error "wrong PALETTE direction, must be \"positive\" or \"negative\", but got: $dir" 1
            }
        }
        
        lassign [array names ::pwtk::gp::palette ${paletteName}*] pal
        if { $pal eq {} } {
            ::pwtk::warning "uknown palette \"$opt(pal)\", using Gnuplot's default instead"
            my options [list palette [concat color model RGB defined]]
        } else {
            my options [list palette [concat color model RGB $::pwtk::gp::palette($pal)]]
        }     
        my options [list palette $dir]
        
        # CONTOUR-related options
        
        if { $opt(cc) ne {} } {
            set color [::pwtk::squote $opt(cc)]
            my add "# color of contours\nset for \[i=1:20\] linetype i linecolor $color"
        }
        if { $opt(nocontour) }  {
            # turn contours off for surface plots
            my unset contour
        }

        # HEAD.TERM
        
        if { $args ne {} } {
            set head [::pwtk::gp::head_ $args]
            set term [::pwtk::gp::term_ $args]
            set args [lrange $argsOrig 0 end-1]
        } else {
            set id [incr ::pwtk::gp::splot_id]
            set head [::pwtk::gp::head_ splot-$id.win]
            set term [::pwtk::gp::term_ splot-$id.win]
            set args $argsOrig
        }

        # -pause
        my pause_ -1 $opt(pause)
        
        # specially handle the -t option
        
        set title {}
        if { $term in $::pwtk::gp::gp(win.terminals) } {
            if { $opt(p) == 0 } {
                set t [string trim "$opt(t) ($pauseText to Exit)"]
            } else {
                set t [string trim "$opt(t) ($pauseText to continue to next page)"]
            }
            set title [list -t $t]
        }

        set prolog [::pwtk::gp::get_term {*}$args {*}$title $head.$term]\n
    }