gnuplot堆积条形图算术

时间:2017-08-07 06:43:37

标签: gnuplot

<div class='dancingtext'>Dancing Text!</div>

创建以下内容: enter image description here

列是累积的。 我想要的是比例,例如在第2行。

tmp.data
DATE         D0 D1 D2 D3 D4 D5
"2017-07-19" 10 8  6  4  2  1
"2017-07-20" 16  14  10 11  10  9
"2017-07-21" 6  5  4  4  3  1
"2017-07-22" 7  5  4  4  3  2 
"2017-07-23" 8  6  4  2  1  1

tmp.gnu
set terminal png size 
set output 'output.png'
set title "statistics"
set key font ",10"
D0 = "#99ffff"; D1 = "#4671d5"; D2 = "#ff0000"; D3 = "#f36e00"; D4 = "#8A2BE2#'; D5 = "#4671d5"
set auto x
unset xtics
set xtics nomirror rotate by -45 scale 0
set style data histogram
set style histogram rowstacked
set style fill solid border -1
set boxwidth 0.75
 plot 'tmp.data' u 2:xtic(1) title columnheader, \
 '' u 3:xtic(1) title columnheader, \
 '' u 4:xtic(1) title columnheader, \
 '' u 5:xtic(1) title columnheader, \
 '' u 6:xtic(1) title columnheader, \
 '' u 7:xtic(1) title columnheader

1 个答案:

答案 0 :(得分:0)

如果要绘制两列之间的差异,则必须计算using语句中的差异,如

plot "tmp.data" using ($2 - $3):xtic(1)

绘制第三列和第二列之间的差异。对于您的所有列,并按原样保留第二列,使用(使用内联数据$data需要5.0):

$data <<EOD
DATE         D0 D1 D2 D3 D4 D5
"2017-07-19" 10 8  6  4  2  1
"2017-07-20" 16  14  10 11  10  9
"2017-07-21" 6  5  4  4  3  1
"2017-07-22" 7  5  4  4  3  2 
"2017-07-23" 8  6  4  2  1  1
EOD

set xtics nomirror rotate by -45 scale 0
set style data histogram
set style histogram rowstacked
set style fill solid border -1
set boxwidth 0.75
set key auto columnheader
 plot $data u 2:xtic(1), \
  for [i=3:7] '' u (abs(column(i) - column(i-1))):xtic(1)

在这里,必须决定是否需要abs。结果是:

enter image description here