4
votes

I work with in-house benchmark tool. I use gnuplot (gnuplot 4.6 patchlevel 4) for visualization.

I need to represent results (method execution times for several runs) as stacked line chart, something like this:

example stacked line chart

Here is an excerpt from my .tsv data file:

Run MethodA MethodB MethodC 
1   192 171 152
2   227 178 161
...
10  229 161 149

And the script I'm using:

#!/usr/bin/gnuplot -p

reset
clear

set terminal png size 640,480
set output "timings.png"
set key top left outside horizontal autotitle columnhead
set title "Third-party REST calls"

set xlabel "Run (ordinal)"
set xtics nomirror scale 0

set ylabel "Time (milliseconds)"
set ytics out nomirror

set grid ytics lt 0 lw 1 lc rgb "#bbbbbb"

set style data histogram
set style histogram rowstacked
set style fill solid border -1
set boxwidth 0.75

plot  "timings.tsv" using 2:xticlabels(1) , "" using 3, "" using 4

I get the following result:

histogram

Yes, it's not a line chart but histogram (I need to represent percentage of execution time of each method). I need slightly different result (the same histogram, not with boxes but with lines which connect boxes tops and with filling below lines), like this:

stacked line diagram - desired diagram

I'm aware of approach with filledcurve's (for instance, described there Creating a Filled Stack Graph in GNUPlot), but in that approach you need to sum values explicitly.

Is it possible to draw filled areas instead of boxes via gnuplot, e.g. convert histogram into stacked line chart?

1
Yes, you must sum explicitely, but that is quite easy using plot for together with the sum function, like in that page you linked at. - Christoph

1 Answers

2
votes

You do need to sum values explicitly, but this is not a big issue. You can script it easily:

firstcol=2
cumulated(i)=((i>firstcol)?column(i)+cumulated(i-1):(i==firstcol)?column(i):1/0)
plot "file.dat" using 1:(cumulated(4)), "" using 1:(cumulated(3)), "" using 1:(cumulated(2))