2
votes

I have created heatmap graphs using gnuplot. I have data.dat:

       avail    reli    perf    
stop    181 20  121 10  34 20
jitter  18 20   17 20   13 20
limp    12 20   5 30    20 20

and gnuplot script:

set term pos eps font 20
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",\
                      20.2 "#FF9999 ",\
                      30.3 "#FF6666",\
                      40.4 "#FF3333",\
                      50.5 "#FF0000",\
                      60.6 "#CC0000",\
                      70.7 "#C00000",\
                      80.8 "#B00000",\
                      90.9 "#990000",\
                      100.0 "#A00000")

set title "Faults"

set ylabel "Hardware Faults"
set xlabel "Aspects"
set size 1, 0.5
set output 'c11.eps'
YTICS="`awk 'BEGIN{getline}{printf "%s ",$1}' 'data2.dat'`"
XTICS="`head -1 'data2.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 )

plot "<awk '{$1=\"\"}1' 'data2.dat' | sed '1 d'" matrix w image, '' matrix using 1:2:($3==0 ? " " : sprintf("%.1d",$3)) with labels
#######^ replace the first field with nothing
################################## ^ delete first line

My output is:

enter image description here

Here I have range 1-20,30-39,...,100 or more) Now I have to 2 values in every axis. e.g stop and avail have(181 and 20). the 181 is the count and 20 is percentages. I want to create graphs which have colors base on percentages and the labels on my graphs from the counts of data.

I have experienced create some graph using for and do some modulo to select the data. But here, I have not idea to create that graphs. Any suggestion for creating this? Thanks!

1

1 Answers

2
votes

You can use every to skip columns.

plot ... every 2 only uses every second column, which is what you can use for the labels. For the colors, you must start with the second column (numbered with 1), and you need every 2::1.

Following are the relevant changes only to your script:

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

The result with 4.6.5 is:

enter image description here