aricb A poster on comp.lang.tcl [L1 ] was looking for code to convert a rectangular set of floating point values into a color image, similarly to MATLAB's imagesc. I used to do some data visualization in a previous life, so I thought I'd bite. Critiques welcome.
The main command is valuesToImg; see comments just inside that proc for available options.
# Aric Bills 2008 # no rights reserved package require math::statistics proc generateDefaultColormap {} { for {set i 0} {$i < 256} {incr i} { lappend colormap [format #%02x%02x%02x $i $i $i] } return $colormap } proc valuesToImg {data args} { # Required argument: # data: a list of lists containing the values to plot; # outer lists are rows; inner lists are columns # Optional arguments: # -photo <handle> # use <handle> instead of creating a new photo object # -colormap <colormaplist> # use <colormaplist> instead of the default 256-level # grayscale map. <colormaplist> should be a list of # valid Tk colors (see man page for Tk_GetColor); the # lowest value in the data maps to the first item in # <colormaplist> # -min <value> # scale data so that all values <value> and lower map # to the first value in the colormap # -max <value> # scale data so that all values <value> and higher map # to the last value in the colormap # get width and height of data set height [llength $data] set width [llength [lindex $data 0]] # ensure that data is numerical and rectangular foreach row $data { if {[llength $row] != $width} { error "data is not rectangular" } foreach item $row { if {![string is double -strict $item]} { error "data contains non-numerical item \"$item\"" } } } # set default values for options set options(-max) [math::statistics::max [join $data]] set options(-min) [math::statistics::min [join $data]] set options(-photo) "" set options(-colormap) [list] # validate optional arguments foreach {key value} $args { switch -- $key { "-max" { if {![string is double -strict $value]} { error "invalid maximum value $value" } } "-min" { if {![string is double -strict $value]} { error "invalid minimum value $value" } } "-photo" { #take this one on faith for now } "-colormap" { #take ths one on faith for now } default { error [concat "unknown option \"$key\"; valid options are:" \ "[lsort -dictionary [array names $options]]"] } } set options($key) $value } if {[llength $options(-colormap)] == 0} { set options(-colormap) [generateDefaultColormap] } if {$options(-photo) eq ""} { set options(-photo) [image create photo \ -width $width \ -height $height] } else { $options(-photo) configure \ -width $width \ -height $height } # populate the image set scaleFactor [expr {([llength $options(-colormap)] - 1) / double($options(-max) - $options(-min))}] set y -1 foreach row $data { incr y set x -1 foreach value $row { incr x set colormapindex \ [expr {int(($value - $options(-min)) * $scaleFactor)}] # make sure $colormapindex is within # 0 to ([llength $options(-colormap)]-1) inclusive set colormapindex [expr { $colormapindex < 0 ? 0 : $colormapindex >= [llength $options(-colormap)] ? [llength $options(-colormap)] - 1 : $colormapindex }] $options(-photo) put \ [lindex $options(-colormap) $colormapindex] \ -to $x $y [expr {$x + 1}] [expr {$y + 1}] } } return $options(-photo) }
if 0 {
Example usage:
}
set sampledata { 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.039 0.471 1.062 1.929 2.756 3.464 3.425 3.030 2.439 2.047 1.692 1.456 1.101 0.510 0.078 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.275 1.652 3.425 4.173 4.329 4.528 5.080 6.063 6.536 7.009 7.048 6.497 5.749 5.040 4.489 4.173 3.739 3.820 3.464 2.243 0.826 0.275 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.353 2.795 4.055 4.173 5.237 7.048 8.348 9.213 9.647 9.961 9.999 9.961 9.922 9.291 9.291 9.174 9.135 9.017 8.544 7.323 5.629 4.290 3.660 3.820 3.660 1.574 0.196 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.826 3.820 4.646 6.259 8.701 9.882 9.017 6.931 5.433 4.489 3.425 2.520 2.126 1.417 1.378 1.140 1.140 1.890 3.660 5.315 7.757 8.661 8.505 8.071 6.457 4.528 3.859 3.621 2.756 1.417 0.235 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.179 4.055 5.315 8.899 9.843 7.992 4.016 1.140 0.510 0.905 0.709 1.022 1.339 1.535 3.150 3.543 3.307 2.991 2.400 1.574 0.669 0.157 0.549 1.809 6.536 9.409 8.308 7.639 5.671 4.016 3.621 3.425 1.535 0.157 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.078 2.243 4.410 6.024 9.529 6.931 2.361 0.157 0.748 1.652 2.520 2.282 2.756 3.229 3.976 3.976 3.859 4.450 5.158 5.119 4.999 4.528 4.881 3.859 1.969 0.314 0.000 0.314 3.069 6.614 9.686 9.765 8.505 5.550 3.820 3.937 1.652 0.039 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.078 2.243 3.976 7.205 9.370 5.040 0.588 0.078 1.260 3.307 3.503 3.898 6.771 8.110 7.953 7.205 6.141 2.952 5.393 5.197 5.158 4.685 3.543 3.859 3.464 2.873 3.069 1.652 0.118 0.157 0.000 0.865 3.820 7.874 9.961 8.860 5.749 4.055 3.503 0.392 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.339 4.450 8.308 8.978 3.543 0.588 0.787 1.339 3.069 2.086 1.652 6.614 7.362 8.071 9.331 9.213 8.071 5.710 8.149 8.308 8.426 8.308 7.600 5.433 1.969 4.055 4.960 3.229 1.218 0.510 0.353 0.157 0.000 0.314 2.361 7.244 9.843 7.874 4.528 3.859 0.944 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.669 3.898 8.899 7.718 2.086 0.431 1.022 1.890 3.346 3.582 4.410 2.126 6.180 7.244 5.237 6.536 8.740 8.191 6.180 8.269 8.701 9.252 9.252 8.899 7.048 4.016 7.284 7.953 7.166 5.827 3.464 2.520 0.709 0.000 0.000 0.275 0.157 3.739 8.821 9.569 5.237 3.976 1.179 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.196 2.165 6.102 6.457 1.101 0.588 1.652 1.809 4.410 4.410 5.788 6.732 4.251 3.820 7.561 5.945 2.479 7.088 8.426 5.788 7.441 8.622 9.213 9.291 8.348 5.749 5.550 8.031 9.056 8.230 7.600 7.166 5.629 3.229 1.062 0.314 0.865 1.652 0.157 1.179 6.024 9.529 5.433 3.859 1.299 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.692 3.582 7.166 1.378 0.118 0.118 2.008 2.599 4.290 5.867 6.024 8.110 6.340 3.859 7.166 7.009 2.439 6.301 8.583 6.141 6.970 8.899 8.978 8.465 6.970 4.999 7.009 8.661 9.056 9.095 9.095 8.978 7.874 6.850 5.158 1.770 0.787 1.022 0.392 0.196 0.078 3.976 8.701 4.881 4.173 1.218 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.709 2.756 6.063 3.190 0.353 1.260 0.669 3.582 3.229 6.141 7.088 4.055 5.354 7.992 7.796 8.269 5.827 2.638 6.654 8.387 5.906 7.639 8.583 7.205 6.850 5.749 6.379 8.348 8.426 7.441 8.779 8.740 8.779 9.135 8.426 7.244 6.141 4.960 2.322 1.339 0.669 1.062 0.078 0.865 6.259 5.197 3.937 1.299 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 2.047 4.881 5.749 0.510 0.314 0.549 4.251 6.575 5.197 4.329 7.639 7.244 4.173 5.867 8.465 5.788 4.999 4.724 6.063 7.992 6.102 8.348 8.505 7.561 8.149 7.953 8.583 8.860 6.889 6.418 8.544 7.205 8.110 9.252 9.056 8.938 8.149 7.519 6.418 2.795 1.731 0.669 0.471 0.471 0.983 6.497 5.119 4.173 0.709 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.944 3.229 6.732 1.692 0.392 0.549 4.133 6.931 8.348 6.340 4.369 7.561 8.622 6.024 4.567 7.323 5.472 5.906 6.379 4.646 7.362 7.796 7.835 8.031 8.622 8.622 7.914 7.401 7.009 5.710 7.244 8.426 6.575 8.505 7.718 6.614 7.796 9.409 8.308 6.180 2.599 3.739 4.212 1.652 0.588 0.392 0.826 5.080 4.251 3.543 0.630 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.157 2.243 5.315 4.251 0.235 0.471 2.873 6.693 8.110 8.701 7.323 4.489 7.166 8.308 6.970 4.999 7.519 6.497 4.881 6.575 4.763 6.457 7.953 5.906 5.354 7.205 8.269 6.180 4.920 4.724 5.906 8.031 8.031 7.166 8.701 5.945 5.984 8.387 9.451 6.654 5.119 4.329 6.654 7.401 6.102 2.638 0.275 0.157 0.588 5.119 4.133 3.030 0.196 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.944 3.030 6.970 1.339 0.510 0.748 3.030 5.788 6.497 8.149 7.914 5.511 5.788 8.031 6.180 3.780 6.102 4.763 4.724 7.284 4.607 4.763 6.220 4.450 5.237 4.724 6.024 7.480 7.088 5.906 5.590 7.561 8.701 8.740 7.914 5.119 7.166 9.213 9.370 8.544 7.362 7.362 8.230 8.031 8.031 6.220 1.809 0.196 0.392 0.630 5.433 3.503 2.008 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.157 2.047 6.575 3.307 0.039 0.588 4.489 4.724 2.599 4.016 4.763 8.191 8.387 7.835 8.821 7.244 4.489 4.763 5.119 4.567 7.874 5.710 4.094 4.803 5.040 7.048 6.063 4.724 6.301 6.889 6.850 4.607 5.945 6.497 7.561 7.519 5.433 7.796 9.291 8.740 8.269 9.135 9.370 8.465 7.284 8.544 6.024 1.969 1.140 0.275 0.157 0.709 5.433 3.425 1.218 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.865 4.055 7.009 0.865 0.000 2.126 6.418 5.906 1.456 3.780 5.119 7.835 7.639 5.511 6.340 7.678 7.639 7.519 5.433 5.827 7.284 7.874 7.835 7.244 7.323 8.505 8.387 6.931 5.710 5.472 7.441 5.749 4.960 3.898 4.960 7.718 5.550 6.889 8.387 9.056 9.135 9.331 9.331 8.230 9.017 8.308 6.141 4.607 1.299 0.787 0.275 0.392 3.937 6.931 2.834 0.353 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.809 6.102 3.109 0.078 0.983 4.369 7.166 7.205 2.952 5.197 6.931 8.230 7.480 5.197 4.251 4.607 4.724 6.024 5.276 6.889 7.284 6.141 7.796 8.860 8.860 8.860 8.938 8.899 8.779 8.583 8.821 8.348 7.323 5.629 4.567 7.284 6.889 5.511 5.433 5.906 7.441 9.017 9.451 9.409 9.686 9.331 7.914 5.550 3.229 3.543 0.669 0.549 0.787 7.048 5.629 2.322 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.353 3.425 5.472 0.471 0.039 1.890 4.881 8.149 7.718 4.763 3.464 6.497 8.269 8.740 8.191 7.441 6.732 5.867 4.960 5.197 5.276 7.757 8.426 8.348 8.308 7.914 8.149 8.269 8.191 8.191 8.230 8.465 8.899 8.978 7.992 4.763 5.197 7.009 7.244 6.379 5.433 5.040 6.575 8.740 8.661 9.174 9.490 9.370 7.127 6.693 6.497 2.126 0.196 0.944 2.520 8.779 3.937 0.196 0.000 0.000 0.000 0.000 0.000 0.000 1.022 5.197 2.795 0.000 1.417 4.450 4.685 7.284 7.914 4.685 6.141 4.920 6.418 7.127 6.931 8.031 8.583 8.031 6.931 7.441 7.718 8.071 7.441 6.771 6.575 6.614 6.970 7.127 7.284 7.362 7.441 7.323 7.441 7.953 8.779 8.387 6.536 5.393 5.749 7.284 7.284 5.393 5.433 6.180 5.984 7.953 9.409 9.569 9.331 6.693 4.763 3.464 1.022 0.471 0.314 7.048 7.088 1.378 0.000 0.000 0.000 0.000 0.000 0.000 1.731 5.276 0.630 0.000 4.369 7.796 7.600 6.457 8.308 6.180 8.031 6.063 3.859 4.290 4.094 6.810 7.561 6.771 8.544 8.544 8.308 6.732 7.519 8.465 8.583 8.583 8.426 8.149 8.149 8.348 8.465 8.505 8.544 8.308 7.992 8.387 8.860 8.505 6.810 5.433 7.323 6.693 5.080 4.173 4.842 7.718 9.529 9.529 9.451 7.561 6.732 7.127 3.543 0.235 0.588 2.991 9.451 2.873 0.039 0.000 0.000 0.000 0.000 0.235 3.699 3.425 0.000 0.669 6.732 8.269 8.899 8.110 8.779 8.622 8.701 8.348 7.127 5.710 4.055 6.810 7.205 4.999 7.639 8.465 6.931 7.441 8.821 8.740 8.661 6.457 2.086 1.101 1.378 1.848 2.834 3.699 5.590 7.796 8.860 8.779 8.544 8.701 8.899 7.561 6.063 8.110 7.600 6.024 4.920 4.960 7.166 9.608 9.765 9.529 9.252 7.835 5.511 1.969 0.549 0.669 8.426 5.080 0.588 0.000 0.000 0.000 0.000 1.179 5.472 0.865 0.000 3.780 8.149 7.166 8.978 8.661 7.127 8.505 7.992 8.387 7.401 6.810 3.937 6.536 7.127 5.080 5.590 7.992 5.710 8.505 8.899 8.821 8.308 1.692 0.669 1.218 1.339 1.179 1.179 0.000 0.000 0.709 2.873 5.749 8.661 8.860 8.779 8.740 8.308 8.110 7.480 7.401 5.393 4.489 6.732 9.135 8.544 7.914 9.213 9.370 7.519 4.094 0.549 0.669 4.724 7.009 1.339 0.000 0.000 0.000 0.000 3.229 3.976 0.039 0.314 5.749 8.544 7.480 8.821 9.135 7.914 8.149 7.992 7.796 6.259 5.867 4.489 6.180 7.401 6.970 5.080 7.048 6.340 8.505 8.779 8.779 7.953 4.881 3.346 4.803 5.315 5.472 4.763 2.520 0.588 0.039 0.039 0.157 1.969 5.827 8.779 9.056 9.174 9.135 8.348 8.387 6.536 4.842 5.393 6.732 8.426 8.661 7.718 9.017 7.166 3.307 1.022 0.196 1.969 8.149 1.770 0.000 0.000 0.000 0.392 4.920 1.929 0.000 1.179 6.889 8.661 8.544 8.544 8.230 7.009 7.914 6.931 7.088 6.614 4.212 5.080 4.881 5.080 6.497 6.379 5.590 6.771 7.718 8.387 8.387 4.960 5.433 4.842 6.732 6.889 7.088 7.088 5.354 1.890 0.431 1.613 2.243 0.865 0.196 3.229 7.992 9.370 9.213 9.252 8.978 8.230 6.301 5.433 4.251 6.259 6.614 6.654 9.370 7.718 5.276 1.456 0.039 0.669 9.252 2.439 0.000 0.000 0.000 1.140 5.749 0.826 0.000 3.464 8.308 8.308 8.544 7.480 7.284 4.016 6.102 4.450 6.850 6.063 5.671 4.489 4.646 6.497 7.480 7.048 6.418 7.048 5.984 7.480 7.088 3.464 5.671 6.497 6.810 6.771 7.323 7.678 7.835 5.827 3.268 4.607 5.788 5.550 2.599 0.196 1.770 8.071 9.451 9.451 9.213 9.056 8.505 6.810 5.629 4.881 6.379 7.796 7.796 9.056 6.732 1.770 0.314 0.353 8.938 3.268 0.000 0.000 0.000 1.770 4.646 0.431 0.196 5.827 8.661 8.387 8.308 6.614 6.970 4.803 6.220 5.393 6.141 6.771 7.048 6.180 4.212 5.315 5.788 6.102 5.827 5.984 5.393 1.299 2.952 5.550 5.945 6.301 6.575 6.970 7.362 7.600 7.561 7.874 6.102 5.511 5.906 6.180 5.945 2.479 0.196 1.652 8.860 9.529 9.370 8.821 8.031 8.191 5.827 5.945 6.931 5.237 6.259 8.149 4.842 1.101 0.630 0.630 8.110 3.660 0.078 0.000 0.000 2.204 4.920 0.392 0.669 6.536 8.622 8.860 8.505 6.340 6.457 6.889 7.953 7.323 7.519 6.180 5.906 7.205 5.629 5.827 4.999 4.251 3.582 3.069 2.873 0.826 4.724 5.710 5.984 6.340 6.614 6.889 7.284 7.441 7.678 7.992 8.149 6.301 5.945 6.340 6.259 5.629 1.339 0.983 8.465 9.686 9.725 9.213 8.505 6.931 5.550 6.614 4.567 5.433 8.661 8.269 6.732 3.660 0.392 0.549 7.718 4.567 0.275 0.000 0.000 3.069 4.567 0.353 1.218 5.158 6.614 8.031 7.835 7.480 7.323 8.149 7.127 6.418 6.063 5.511 6.889 7.166 6.575 5.590 4.410 3.190 2.008 1.456 2.834 1.731 3.820 4.842 5.945 6.850 7.166 7.284 7.480 7.519 7.519 8.269 8.821 7.914 6.301 6.497 6.301 6.102 3.307 5.237 9.490 9.725 9.529 8.938 8.583 7.678 5.671 5.749 4.567 7.441 6.497 4.251 5.472 3.030 0.078 0.275 7.127 5.354 0.588 0.000 0.078 4.290 4.803 0.353 2.716 7.441 7.048 7.166 5.237 7.600 7.757 6.810 7.480 4.920 5.590 5.788 6.259 4.329 3.660 2.873 2.795 2.243 2.361 2.479 1.969 2.559 1.218 4.094 6.850 7.284 7.284 7.441 7.757 7.953 7.441 8.110 8.779 8.544 7.088 6.418 6.180 5.984 6.418 9.252 9.647 9.213 8.110 7.992 7.718 7.048 6.771 5.472 5.590 9.056 8.149 5.590 4.329 1.062 0.000 0.000 5.315 5.906 0.865 0.000 0.157 5.080 5.354 0.471 2.086 8.583 7.519 6.614 6.654 7.678 7.639 5.472 7.401 6.771 5.040 4.489 4.055 2.873 3.660 2.559 5.276 4.881 3.859 5.590 3.937 1.140 1.731 6.575 7.323 7.519 7.796 8.149 8.191 8.149 8.191 8.269 8.031 8.505 6.970 5.945 5.984 6.259 8.583 9.252 8.938 8.191 7.561 6.732 5.040 3.660 3.937 5.080 7.244 8.348 9.291 8.465 6.180 1.456 0.000 0.000 4.055 5.906 1.101 0.000 0.275 5.433 4.369 0.510 0.353 5.472 7.796 8.583 7.835 7.678 5.710 5.590 6.693 6.575 4.369 4.842 4.329 3.859 5.827 3.582 5.590 4.251 4.920 5.788 4.410 2.912 5.158 7.441 7.244 7.718 8.269 8.230 7.953 8.387 7.992 7.718 7.284 6.810 5.867 5.749 6.063 8.031 7.874 6.850 6.536 6.259 5.354 5.158 5.629 7.205 7.796 7.519 6.771 8.779 8.308 5.590 2.716 0.196 0.000 0.000 3.543 6.141 1.140 0.000 0.314 6.180 4.212 0.510 0.039 1.969 8.149 8.426 7.914 7.757 6.654 4.803 5.629 4.173 4.920 5.671 4.724 4.055 5.788 4.567 5.788 4.251 6.220 4.960 5.119 3.582 5.237 7.639 7.401 7.639 7.874 7.639 7.323 7.205 6.340 5.945 6.379 6.102 5.590 5.906 7.718 8.426 7.835 6.102 5.867 4.685 5.788 7.441 7.480 5.867 5.629 5.472 8.348 9.331 5.984 3.109 0.392 0.000 0.000 0.000 2.520 6.614 1.179 0.000 0.275 6.259 4.528 0.787 0.000 0.196 3.621 6.497 5.984 6.063 5.197 3.898 5.433 5.945 4.999 6.141 5.276 4.999 5.629 5.354 5.945 5.315 6.259 5.710 6.102 4.016 5.197 7.519 7.323 7.323 7.441 7.401 7.914 7.678 2.008 3.464 5.080 2.165 4.803 6.220 6.931 6.180 8.387 8.860 9.017 8.622 8.661 7.048 6.614 7.600 8.191 8.149 9.331 9.686 7.600 5.276 0.235 0.000 0.000 0.000 1.218 6.810 1.339 0.000 0.235 5.276 4.763 0.944 0.000 0.000 0.078 2.361 3.898 3.307 4.450 5.119 4.685 5.788 6.379 6.024 5.749 5.119 5.749 6.340 6.654 6.810 6.810 6.180 5.827 4.212 6.850 7.205 7.323 7.009 7.323 8.191 8.230 3.699 0.588 0.944 1.456 1.417 2.677 4.646 5.276 5.511 7.205 7.127 6.889 8.031 8.465 8.426 7.992 6.102 4.803 4.607 6.457 8.387 6.693 2.638 0.000 0.000 0.000 0.118 1.218 6.970 1.260 0.000 0.118 5.080 6.063 2.008 0.039 0.000 0.314 0.157 2.991 3.386 5.393 6.024 5.749 4.055 5.040 6.575 7.244 6.614 6.931 7.600 7.561 7.362 7.009 5.827 4.842 5.945 7.205 7.323 7.953 7.757 7.914 8.191 7.244 2.638 1.731 0.865 0.826 1.179 1.652 1.535 4.290 5.276 5.710 5.393 3.739 4.016 4.999 5.433 4.212 3.739 4.410 5.511 6.379 5.906 2.559 0.000 0.000 0.000 0.471 0.983 2.204 6.889 0.748 0.000 0.000 4.685 8.505 3.699 1.731 0.000 0.118 0.000 0.669 4.410 5.511 4.290 5.671 6.457 6.102 6.180 7.718 7.914 7.718 7.323 7.088 7.480 7.166 6.889 6.693 7.166 7.205 7.914 7.992 7.835 8.071 8.191 7.519 1.969 2.991 0.787 0.709 0.944 1.022 3.346 5.710 6.141 4.212 3.464 2.912 2.243 2.439 2.559 3.268 2.361 0.865 0.353 0.471 0.157 0.000 0.000 0.000 0.157 3.780 1.339 5.788 5.080 0.118 0.000 0.000 3.621 9.765 4.567 3.386 2.439 0.118 0.471 0.510 5.393 6.379 5.788 5.827 5.867 6.970 7.757 7.441 7.796 7.678 6.575 4.646 4.685 6.259 6.850 7.088 6.931 7.480 8.031 7.953 7.678 7.914 8.149 7.441 1.652 0.669 1.062 1.456 1.929 1.929 1.809 2.638 1.929 0.905 0.000 0.039 0.078 0.471 0.669 0.471 0.000 0.000 0.000 0.235 0.157 0.000 0.000 0.000 1.299 3.069 4.763 7.127 1.809 0.000 0.000 0.000 2.439 9.135 5.906 2.912 4.329 3.030 0.157 0.078 4.133 5.629 6.693 6.732 6.970 7.009 6.180 4.960 6.889 7.127 4.528 3.739 2.795 1.848 4.685 7.127 7.166 7.441 7.796 7.835 7.874 7.992 8.269 6.654 0.983 2.204 2.756 3.346 3.464 3.346 1.652 0.709 0.118 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.630 0.549 0.000 0.000 0.039 1.378 4.410 5.749 4.999 0.157 0.000 0.000 0.000 1.574 7.519 8.465 2.873 2.795 5.276 1.652 0.000 1.417 5.276 5.827 5.710 6.220 5.827 5.197 4.881 6.418 5.237 5.119 6.220 5.629 3.739 3.660 7.205 7.205 7.519 7.796 7.874 7.796 8.071 8.308 5.511 1.613 2.991 1.299 2.047 1.848 1.179 0.235 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 1.022 4.528 5.945 5.827 1.022 0.000 0.000 0.000 0.000 0.787 5.945 9.569 4.212 2.991 4.055 5.119 0.905 0.000 0.865 4.173 5.945 5.393 5.945 5.158 5.393 5.590 3.229 5.867 6.771 6.457 5.158 4.489 7.362 7.244 7.441 7.757 7.835 7.835 8.110 7.757 2.912 2.165 0.983 1.260 0.905 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.118 0.039 0.000 0.000 0.000 0.000 0.000 0.078 0.000 0.000 0.000 0.000 1.969 5.749 6.970 3.109 0.000 0.000 0.000 0.000 0.000 0.549 5.511 9.569 5.550 4.607 3.976 5.472 4.173 0.235 0.471 0.353 3.109 5.433 5.671 4.016 4.055 4.724 4.960 6.102 6.141 5.827 5.511 5.393 7.323 6.889 6.301 7.480 7.914 8.031 7.718 4.567 1.929 1.495 1.652 0.826 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.039 2.243 0.669 0.748 0.118 0.000 0.000 0.000 1.062 0.353 0.118 0.039 0.000 1.929 5.788 4.960 1.101 0.000 0.000 0.000 0.000 0.000 0.709 5.315 9.409 6.102 3.386 4.212 4.960 5.788 3.464 0.549 1.022 0.118 1.218 2.361 1.456 1.613 1.770 5.080 5.906 6.259 6.340 5.867 5.945 7.480 7.088 6.024 5.433 7.323 6.259 2.991 1.260 1.260 2.756 2.677 1.378 0.078 0.000 0.000 0.000 0.000 0.000 0.000 1.495 3.307 1.652 0.510 1.299 1.140 0.353 1.378 3.307 2.204 2.834 0.865 0.000 0.865 4.369 5.511 2.479 0.000 0.000 0.000 0.000 0.000 0.865 5.550 9.135 6.259 3.543 3.386 4.646 4.646 6.771 4.173 2.439 2.282 0.392 0.039 0.039 0.235 1.378 5.197 6.220 6.614 6.771 5.867 6.379 7.480 7.480 6.889 2.520 1.339 1.101 0.709 0.709 2.361 4.212 3.543 1.848 1.969 0.353 0.000 0.118 0.275 0.078 0.235 1.179 2.834 2.322 2.361 2.243 1.535 1.456 3.229 3.582 3.425 3.582 2.638 2.834 2.559 2.873 6.889 5.237 0.826 0.000 0.000 0.000 0.000 1.022 5.788 7.561 5.393 3.820 3.030 3.937 4.133 5.315 8.505 5.276 4.450 3.190 1.101 0.196 0.039 1.218 5.629 5.511 5.354 5.550 5.433 6.693 7.362 7.480 6.180 1.652 0.510 0.630 0.314 2.204 5.276 3.739 2.559 2.716 3.069 2.873 3.307 3.820 1.574 1.613 4.016 4.251 4.567 5.315 5.393 5.197 4.803 4.212 3.820 3.898 4.410 4.133 3.699 4.369 4.173 4.489 8.661 6.457 2.716 0.039 0.000 0.000 0.078 1.417 6.259 7.600 5.237 4.763 3.543 3.464 3.898 4.329 6.301 8.661 4.410 4.410 4.290 2.873 0.865 0.471 4.646 5.671 5.788 5.040 3.543 5.119 6.379 6.732 3.582 1.848 1.535 0.275 1.299 4.528 2.559 1.339 1.535 2.716 4.410 6.141 4.685 1.574 0.039 0.905 3.543 4.607 4.724 5.080 4.803 4.842 4.803 4.489 4.369 4.489 4.450 3.030 1.731 2.834 3.699 3.229 5.433 5.550 5.433 0.314 0.000 0.000 0.157 2.400 5.472 6.970 5.788 5.550 4.212 2.834 3.543 4.016 4.489 7.519 7.600 3.859 4.763 4.528 2.243 0.471 0.787 2.008 2.361 1.456 0.669 2.559 3.307 2.439 1.062 0.549 0.196 0.787 5.158 3.150 1.613 2.047 2.912 4.369 5.393 5.080 3.425 0.039 1.179 3.543 3.386 3.190 3.464 3.820 4.212 4.489 4.212 4.685 4.881 4.803 5.040 4.685 2.756 2.677 3.503 3.307 4.410 4.960 6.889 1.417 0.000 0.000 0.196 2.599 4.212 6.614 5.393 5.158 5.158 2.952 3.425 4.016 4.173 6.340 9.095 5.276 3.976 5.315 4.329 1.929 1.495 1.535 0.392 0.275 0.630 1.613 0.826 0.471 0.549 0.196 0.196 3.976 4.528 3.307 3.780 4.290 4.842 5.393 5.237 4.133 0.630 0.039 3.268 4.528 4.763 4.920 5.354 5.354 5.354 4.489 2.873 2.479 2.520 3.346 4.803 6.457 6.889 6.063 3.859 3.030 5.984 5.590 8.071 3.739 0.039 0.000 0.078 2.204 4.489 5.511 5.080 5.671 4.999 3.069 3.307 3.820 3.898 5.788 8.071 8.821 4.329 3.307 4.055 3.503 2.677 2.165 0.471 0.235 0.471 1.140 0.392 0.314 0.471 1.731 2.204 3.621 6.575 5.906 4.960 5.080 5.906 5.984 4.646 1.339 0.000 0.392 3.859 4.607 5.040 5.119 5.237 3.346 1.692 1.495 0.826 0.275 0.549 1.809 4.450 6.220 6.654 7.401 7.441 7.639 8.071 7.009 9.409 5.080 0.630 0.000 0.039 2.322 4.094 5.276 5.080 5.984 5.590 3.346 3.386 4.133 3.859 5.393 6.693 7.480 8.465 5.906 4.212 7.127 7.127 3.660 0.748 0.196 0.588 0.944 0.471 0.630 1.378 2.912 3.859 6.141 7.127 6.024 5.276 5.276 6.063 5.354 2.834 0.196 0.000 0.196 3.739 4.528 4.842 5.158 5.590 5.511 4.999 4.607 4.173 4.133 4.567 5.710 6.771 7.166 7.127 7.401 8.071 8.583 7.678 7.205 9.686 5.906 2.795 } foreach line [split $sampledata \n] { if {[llength $line] > 0} { lappend listOfLists $line } } set img [valuesToImg $listOfLists] set img2 [image create photo] $img2 copy $img -zoom 3 toplevel .viewData set label [label .viewData.label -image $img2] grid $label
if 0 {
It's the user's job to clean up $img and $img2.
}