Print Sprintf error while input is a string consisting of a character in the planet gnuplot

I am working on a heatmap with a unique dataset. A data set consists of a symbol. Here is an example of my 1q.txt dataset

            one         two         three   
2009        0/0    1    0/0    1    0/0      1      
2010        0/0    1    0/0    1    0/0      1      
2011        0/0    1    0/0    1    6/179.5  1  
2012        0/0    1    2/0.4  1    11/83.0  1
2013        7/0.8  1    7/21.3 1    17/268.5 1
2014        1/3.5  1    4/7.7  1    9/37.9   1

and here is my gnuplot script

set term pos eps font 20
unset colorbox
unset key
set nocbtics
set cblabel "Score" 
set cbtics scale 0
set cbrange [ 0.00000 : 110.00000 ] noreverse nowriteback
set palette defined ( 0.0 "#FFFFFF",\
                      1 "#FFCCCC",\
                      2 "#FF9999 ",\
                      3 "#FF6666")

set size 1, 0.5
set output '1q.eps'
YTICS="`awk 'BEGIN{getline}{printf "%s ",$1}' '1q.dat'`"
XTICS="`head -1 '1q.dat'`"
set for [i=1:words(XTICS)] xtics ( word(XTICS,i) i-1 )
set for [i=1:words(YTICS)] ytics ( word(YTICS,i) i-1 )

set for [i=1:words(XTICS)] xtics ( word(XTICS,i) 2*i-1 )
plot "<awk '{$1=\"\"}1' '1q.dat' | sed '1 d'" matrix every 2::1 w image, \
     '' matrix using ($1+1):2:(sprintf('%.f', $3)) every 2 with labels

What I'm trying to do here is that I want to display "0/0" as a label in the heat map and an integer as the color of the heat map.

The problem I am encountering here is that gnuplot only accepts a number before "/" and ignore the other.

Here is the result of my current plot.

enter image description here

How to make Heatmap display a layout like "1 / 3.5" and have a color based on an integer.

+1
1

sprintf . stringcolumn, , :

plot "<awk '{$1=\"\"}1' '1q.dat' | sed '1 d'" matrix every 2::1 w image, \
 '' matrix using ($1+1):2:(stringcolumn(3)) every 2 with labels
+1

Source: https://habr.com/ru/post/1622109/


All Articles