gnuplot堆叠填充曲线可以';不显示正确的总数

gnuplot堆叠填充曲线可以';不显示正确的总数,gnuplot,stacked,curves,Gnuplot,Stacked,Curves,目前我正在研究Gnulot堆叠填充曲线。我有问题使我的图表堆叠。 这是我的数据: prog reli perf avail sec cons topo scale qos 2011 138 90.3 21.0 63.5 45.5 48.5 6.8 4.0 5.5 2012 191.3 77.8 90.8 30.8 29.0 22.1 2.0 1.0 1.0 2013 85.0 5

目前我正在研究Gnulot堆叠填充曲线。我有问题使我的图表堆叠。 这是我的数据:

     prog   reli    perf    avail   sec cons    topo    scale   qos
2011 138    90.3    21.0    63.5    45.5    48.5    6.8 4.0 5.5
2012 191.3  77.8    90.8    30.8    29.0    22.1    2.0 1.0 1.0
2013 85.0   57.5    48.0    20.0    27.5    8.5 0   2.5 1.0
2014 2.0    0.5 1.0 2.0 1.0 1.5 0   0   0
我已经在t1.plt上绘图了

set term pos eps font 20
set output 't1.eps'
set pointsize 0.8
set border 11
set xtics out
set tics front
set key below
set multiplot
a=0
plot for [i=1:9] "t1" using (column(i)):xtic(1) t column(i) with filledcurves
我的当前输出:

我希望创建如下图表: 关于风格的注释:

plot
命令的末尾添加
x1
,使曲线朝(下部)x轴闭合(
x2
将为上部)。还要注意,在这种情况下,
set multiplot
是不必要的。最后,迭代中的标题应该来自
列(i-1)
,而不是
列(i)
,或者向数据文件中的第一列添加标签,并且迭代应该从2到10运行,除非您想将第一列自身绘制出来

使用数据和以下命令:

plot for [i=2:10] \
"t1" using (column(i)):xtic(1) t column(i-1) with filledcurves x1
我得到:

将图形堆叠起来有点复杂,因为它需要将连续的列相加,可以使用awk完成,在gnuplot中调用:

set xtics 1
plot for [i=10:2:-1] \
"< awk 'NR==1 {print \"year\",$".(i-1)."} NR>=2 {for (i=2; i<=".i."; i++) \
{sum+= $i} {print $1, sum; sum=0} }' t1" \
using (column(2)):xtic(1) with filledcurves x1 t column(2)

以下是仅使用gnuplot的方法。您可以使用
sum
命令对列值求和,以获得堆叠图形:

set terminal postscript eps color font 20
set output 't1.eps'
set xtics 1 out
set tics front
set key invert
set style fill solid noborder
plot for [i=10:2:-1] "t1" using 1:(sum [col=2:i] column(col)) with filledcurves x1 title columnheader(i-1)
请注意,列标题的索引为1..9,而值为2..10。因此,您必须明确使用
标题列标题(i-1)
。如果您想给第一列也加一个标题,例如
year
,您可以使用
set key autotitle columnheader

不幸的是,
set key
invert
选项仅对列有效。因此,如果使用倒置下方的设置键,则无法获得数据文件的原始顺序

结果见4.6.4:


谢谢@miguel。。顺便问一下,这是什么?我想每个类别都是从零开始的。我希望下一个类别从上一个类别的末尾开始。i、 e:Prog0-20和reli应该从20-30开始,以此类推。这显然是正确的答案。既然
sum
实现了什么版本?@Miguel这是从4.6.0开始的。唯一的问题可能是单键标签的顺序,因为
invert
不能完全反转。@Christoph:你永远是个英雄。谢谢@克里斯托夫,关于传奇骑士团的小事情。订单应为perf、avail、sec等。我还可以在曲线顶部看到任何橙色。这不是真的吗?@indi60查看编辑。在我以前的版本中也缺少一个专栏。如果还要反转线型,则必须添加
lt i-1
set terminal postscript eps color font 20
set output 't1.eps'
set xtics 1 out
set tics front
set key invert
set style fill solid noborder
plot for [i=10:2:-1] "t1" using 1:(sum [col=2:i] column(col)) with filledcurves x1 title columnheader(i-1)