Currently I working on Gnulot stacked filledcurves. I have problem to make my graphs stacked. This is my data:
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
I have plotted on 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
my current output:
my expectation to create graphs like this link:
Here is how you can do this with gnuplot only. You can use the
sum
command for the summation of the column values in order to get a stacked graph:Note, that the indices for the column headers are 1..9, whereas the values go from 2..10. So you must explicitely use
title columnheader(i-1)
. If you would give the first column also a header, e.g.year
, you could useset key autotitle columnheader
.Unfortunately, the
invert
option ofset key
works only on the columns. So if you useset key below invert
, you don't get the original order of your data file.Result with 4.6.4:
Notes on style:
Add
x1
at the end of yourplot
command so the curves will be closed towards the (lower) x axis (x2
would be the upper one). Note also thatset multiplot
is unnecessary in this case. Finally, the title in your iteration should come fromcolumn(i-1)
rather thancolumn(i)
, or else add a label to the first column in your data file, and the iteration should run from 2 to 10, unless you want to plot the first column against itself too.With your data and the following command:
I get:
Getting the graphs stacked is a bit more complicated as it involves adding up consecutive columns, it can be done with awk, invoked within gnuplot:
You can execute the
awk
part alone outside gnuplot to see what it does to your data: