matrix - Display label on gnuplot value in heatmap -


base on gnuplot example "heat map non-zero pixel values written labels" in here: http://gnuplot.sourceforge.net/demo_cvs/heatmaps.html

i have data:

6 5 4 3 1 0 3 2 2 0 0 1 0 0 0 0 1 0 0 0 0 0 2 3 0 0 1 2 4 4 0 1 2 3 4 6 

and gnuplot:

set terminal pngcairo enhanced font "arial,10" fontscale 1.0 size 500, 350  set output 'heatmaps.png'  unset key set view map set xtics border in scale 0,0 mirror norotate  offset character 0, 0, 0 autojustify set ytics border in scale 0,0 mirror norotate  offset character 0, 0, 0 autojustify set ztics border in scale 0,0 nomirror norotate  offset character 0, 0, 0 autojustify set nocbtics set rtics axis in scale 0,0 nomirror norotate  offset character 0, 0, 0 autojustify set xrange [ -0.500000 : 4.50000 ] noreverse nowriteback set yrange [ -0.500000 : 4.50000 ] noreverse nowriteback set cbrange [ 0.00000 : 5.00000 ] noreverse nowriteback set palette rgbformulae -7, 2, -7 splot 'heatmap.txt' matrix using 1:2:3 image, \       'heatmap.txt' matrix using 1:2:($3 == 0 ? " " : sprintf("$3") ) labels 

this script printout "3" in every labels. me? thanks

and label xtics , ytics

 tipe1 tipe2 tipe3 tipe4 tipe5 failure1 6 2 0 0 1 failure2 0 0 0 1 0 failure3 0 0 0 2 3 failure4 0 1 2 4 4 failure5 1 2 3 4 6 

thanks again

i think problem wrong call sprintf function.

sprintf(format,values) 

you should call sprintf decimal number in format (%d) , label value want display (third column $3) :

sprintf("%d",$3)  

i copied data file (named data) , example works :

plot 'data' matrix using 1:2:3 image, '' matrix using 1:2:($3==0 ? " " : sprintf("%d",$3)) labels   

hope helps!


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -