Created
October 9, 2009 09:01
-
-
Save rjp/205876 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make a heatmap legend for ploticus scatterplot heatmaps | |
# using colors.png as a palette, first pixel of each line | |
# > echo png2html > /tmp/.png.$$ | |
# > png2html colors.png /tmp/.png.$$ test_png.html 2 | |
# > perl -nle '/#(......)/ && print "$1"' test_png.html > colors.txt | |
legentry () { | |
a="xrgb($1)"; b=$1; c="$2+" | |
if [ ${b:0:1} = "-" ]; then a="${b:1}"; fi | |
if [ "$3" ]; then c="$2-$3"; fi | |
cat <<LEG | |
#proc legendentry | |
sampletype: color | |
details: $a | |
tag: $2 | |
label: $c | |
LEG | |
} | |
end=145 | |
lines=$(cat colors.txt | wc -l) | |
scale=$((echo scale=5; echo $lines/$end)|bc) | |
for i in $(seq $end -10 10); do | |
kk=$((echo "($i*$scale)/1")|bc) | |
j=$(sed -ne ${kk}p < colors.txt) | |
legentry $j $i $last | |
last=$((i-1)) | |
done | |
legentry "35343D" 1 $last | |
legentry "-black" 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment