in reply to Re^3: visualizing data in a table
in thread visualizing data in a table
I'm using it in a loop like so: $img->setPixel($x, $y, $some_val_from_a_table , 1,16 )) ; it works ok but sometime produces colours which are too near to each other to be distinguished easily. Browser_Uk , how di dyou write your colour ramp ? I read about some colour ramps <-- here, but not sure if they fit the common usage.my @map=( sub{( 0, 0, $_[0] * 255 )}, sub{( 0, $_[0]*255, 255 )}, sub{( 0, 255, (1-$_[0])*255 )}, sub{( $_[0]*255, 255, 0 )}, sub{( 255, (1-$_[0])*255, 0 )}, sub{( 255, 0, $_[0]*255 )}, sub{( 255, $_[0]*255, 255 )}, ); sub ramp { my( $v, $vmin, $vmax ) = @_; ## Peg $v to $vmax if it is greater than $vmax $v = $vmax if $v > $vmax; ## Or peg $v to $vmin if it is less tahn $vmin. $v = $vmin if $v < $vmin; ## Normalise $v relative to $vmax - $vmin $v = ( $v - $vmin ) / ( $vmax - $vmin ) ; ## Scale it to the range 0 .. 1784 $v *= 1785; my @a = map { int } $map[$v/255]->( ($v % 255) / 256 ); #print join(',',@a)."\n"; return ($a[2]<<8 ) | ($a[1]<<4 ) | ($a[0] ) ; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: visualizing data in a table
by BrowserUk (Patriarch) on Mar 31, 2010 at 17:53 UTC |