diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2019-07-26 18:25:06 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2019-07-26 18:25:06 (GMT) |
commit | f7ccea415512fbfb10dc4db1122044db0bc63c7c (patch) | |
tree | 7bb27849e85b5b9cc469fb8231fe006a862d9cf0 /ds9 | |
parent | d8c39d6f32ab089a7a2d2727fafcd80771846aa2 (diff) | |
download | blt-f7ccea415512fbfb10dc4db1122044db0bc63c7c.zip blt-f7ccea415512fbfb10dc4db1122044db0bc63c7c.tar.gz blt-f7ccea415512fbfb10dc4db1122044db0bc63c7c.tar.bz2 |
support multiple graphs per plot
Diffstat (limited to 'ds9')
-rw-r--r-- | ds9/library/plot.tcl | 89 |
1 files changed, 53 insertions, 36 deletions
diff --git a/ds9/library/plot.tcl b/ds9/library/plot.tcl index ff9f96e..b9ff6b9 100644 --- a/ds9/library/plot.tcl +++ b/ds9/library/plot.tcl @@ -480,38 +480,40 @@ proc PlotListGenerate {varname} { upvar #0 $varname var global $varname + if {$var(graph,ds,xdata) == {}} { + return + } + + global $var(graph,ds,xdata) $var(graph,ds,ydata) \ + $var(graph,ds,xedata) $var(graph,ds,yedata) + set ll [$var(graph,ds,xdata) length] + set xx [$var(graph,ds,xdata) range] + set yy [$var(graph,ds,ydata) range] + set rr {} - if {$var(graph,ds,xdata) != {}} { - global $var(graph,ds,xdata) $var(graph,ds,ydata) \ - $var(graph,ds,xedata) $var(graph,ds,yedata) - set ll [$var(graph,ds,xdata) length] - set xx [$var(graph,ds,xdata) range] - set yy [$var(graph,ds,ydata) range] - - switch $var(graph,ds,dim) { - xy { - for {set ii 0} {$ii<$ll} {incr ii} { - append rr "[lindex $xx $ii] [lindex $yy $ii]\n" - } + switch $var(graph,ds,dim) { + xy { + for {set ii 0} {$ii<$ll} {incr ii} { + append rr "[lindex $xx $ii] [lindex $yy $ii]\n" } - xyex { - set xe [$var(graph,ds,xedata) range] - for {set ii 0} {$ii<$ll} {incr ii} { - append rr "[lindex $xx $ii] [lindex $yy $ii] [lindex $xe $ii]\n" - } + } + xyex { + set xe [$var(graph,ds,xedata) range] + for {set ii 0} {$ii<$ll} {incr ii} { + append rr "[lindex $xx $ii] [lindex $yy $ii] [lindex $xe $ii]\n" } - xyey { - set ye [$var(graph,ds,yedata) range] - for {set ii 0} {$ii<$ll} {incr ii} { - append rr "[lindex $xx $ii] [lindex $yy $ii] [lindex $ye $ii]\n" - } + } + xyey { + set ye [$var(graph,ds,yedata) range] + for {set ii 0} {$ii<$ll} {incr ii} { + append rr "[lindex $xx $ii] [lindex $yy $ii] [lindex $ye $ii]\n" } - xyexey { - set xe [$var(graph,ds,xedata) range] - set ye [$var(graph,ds,yedata) range] - for {set ii 0} {$ii<$ll} {incr ii} { - append rr "[lindex $xx $ii] [lindex $yy $ii] [lindex $xe $ii] [lindex $ye $ii]\n" - } + } + xyexey { + set xe [$var(graph,ds,xedata) range] + set ye [$var(graph,ds,yedata) range] + for {set ii 0} {$ii<$ll} {incr ii} { + append rr "[lindex $xx $ii] [lindex $yy $ii] [lindex $xe $ii] [lindex $ye $ii]\n" } } } @@ -611,23 +613,38 @@ proc PlotUpdateCanvas {varname} { set first [lindex $var(graphs) 0] set last [lindex $var(graphs) end] + + if {[info exists ${varname}($first,1,xdata)]} { + set xmin [blt::vector expr min($var($first,1,xdata))] + set xmax [blt::vector expr max($var($first,1,xdata))] + } else { + set xmin 0 + set xmax 1 + } + if {[info exists ${varname}($first,1,ydata)]} { + set ymin [blt::vector expr min($var($first,1,ydata))] + set ymax [blt::vector expr max($var($first,1,ydata))] + } else { + set ymin 0 + set ymax 1 + } if {$var(layout,lock)} { set var(layout,axis,x,log) $var($first,axis,x,log) set var(layout,axis,x,flip) $var($first,axis,x,flip) - set var(layout,axis,x,min) 1 - set var(layout,axis,x,max) 10 + set var(layout,axis,x,min) $xmin + set var(layout,axis,x,max) $xmax set var(layout,axis,y,log) $var($first,axis,y,log) set var(layout,axis,y,flip) $var($first,axis,y,flip) - set var(layout,axis,y,min) 0 - set var(layout,axis,y,max) 9 + set var(layout,axis,y,min) $ymin + set var(layout,axis,y,max) $ymax } else { set var(layout,axis,x,log) 0 set var(layout,axis,x,flip) 0 - set var(layout,axis,x,min) {} - set var(layout,axis,x,max) {} - set var(layout,axis,y,min) {} - set var(layout,axis,y,max) {} + set var(layout,axis,x,min) 0 + set var(layout,axis,x,max) 1 + set var(layout,axis,y,min) 0 + set var(layout,axis,y,max) 1 } foreach cc $var(graphs) { |