I'm plotting graphs with GNUPlot. I'm able to generate a stacked histogram with a legend, but I'm struggling to extend the legend with MIX,MAX,etc values per item, something like I managed to get with RRDTool
My data looks something like this
DATE 2GRAN 3GRAN 4GRAN 2GTRAN
20170401 1234 1232 5454 98765
20170402 2312 99999 11 1234
20170403 55 654 1123 10000
but with more columns.
The code I'm using is:
clear
reset
set key out
set terminal jpeg size 1900,1080 font "Helvetica" 16
set output 'plot_per_mo.jpg'
set xtics rotate out
set style data histogram
set style histogram rowstacked
set boxwidth 0.7 relative
set datafile missing '?'
set datafile separator '\t'
do for [i=2:13]{
stats 'convertedDataMO.dat' using (column(i))
max(i) = STATS_max
print sprintf("Max[%2d] = %d",i,max(i))
}
set palette defined ( 0 "black", 1 "yellow", 2 "green", 3 "blue", 4 "red", 5 "orange" )
plot for [COL=2:13] 'convertedDataMO.dat' using COL:xticlabels(1) lt palette frac COL/13. title columnheader(COL)
I tried to use
plot for [COL=2:13] 'convertedDataMO.dat' using COL:xticlabels(1) lt palette frac COL/13. title sprintf("%20s ---> %6d",columnheader(COL),max(COL))
But I have two problems with it.
- columnheader is not recognized as string
- max(COL) is only showing last value (tested after removing columnheader from sprintf)
I'm new to gnuplot, so I'm sure I'm missing something important here