In Japan, we often connect the corresponding components of stacked histogram graph wit lines.
See attached example.
But it is difficult to make such graphs by gnuplot of current version. We want such option for histogram.
It is not often used, I think (tried Google), and for a good reason: Most of the time, if boxes are used (stacked or not), lines have no meaning and vice versa.
Here is an approximation of what you want (imho, less unpleasant to the eye as with the steeper lines you aim at):
$data << EOD
1920 55 21 24
1940 45 26 29
1960 33 29 38
1980 11 34 55
2000 5 30 65
EOD
set boxwidth 0.7 relative
set style fill solid
set key noautotitle outside center left reverse spacing 2 samplen 1.5
set xrange [1907:2013]
plot $data \
using 1:($2+$3+$4) w l lc rgb 'black', '' \
using 1:($2+$3) w l lc rgb 'black', '' \
using 1:2 w l lc rgb 'black', '' \
using 1:($2+$3+$4) w boxes title 'cat 3', '' \
using 1:($2+$3) w boxes title 'cat 2', '' \
using 1:2 w boxes title 'cat 1'
I started using 'histogram rowstacked' but failed adding the lines.
Last edit: Rainald Koch 2017-02-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your reply. I know several ways to write such graph (in fact, attached graph is also made by gnuplot), but they are not simple. For example, using array and set arrow.
set style fill solid
set key noautotitle outside center left reverse invert spacing 2 samplen 1.5
bw = 0.7
set boxwidth bw
set style histogram rowstacked
stats $data using 1 nooutput name 'A'
set xrange [-bw:A_records-1+bw]
array d1[A_records]
array d2[A_records]
j=0
stats $data using (j=j+1, d1[j] = $2, d2[j] = $2+$3) nooutput
set style arrow 1 nohead lt 1 lc black dt 2
set for [j=2:A_records] arrow from (j-2+bw/2),d1[j-1] to (j-1-bw/2),d1[j] as 1
set for [j=2:A_records] arrow from (j-2+bw/2),d2[j-1] to (j-1-bw/2),d2[j] as 1
plot $data \
using 2:xtic(1) with hist, '' \
using 3 with hist, '' \
using 4 with hist
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This kind of plot can be constructed in gnuplot 6.1 using the newly introduced plot style with hsteps. However the available options are quite different from with histogram.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is not often used, I think (tried Google), and for a good reason: Most of the time, if boxes are used (stacked or not), lines have no meaning and vice versa.
Here is an approximation of what you want (imho, less unpleasant to the eye as with the steeper lines you aim at):
I started using 'histogram rowstacked' but failed adding the lines.
Last edit: Rainald Koch 2017-02-26
Thanks for your reply. I know several ways to write such graph (in fact, attached graph is also made by gnuplot), but they are not simple. For example, using array and set arrow.
set style fill solid
set key noautotitle outside center left reverse invert spacing 2 samplen 1.5
bw = 0.7
set boxwidth bw
set style histogram rowstacked
stats $data using 1 nooutput name 'A'
set xrange [-bw:A_records-1+bw]
array d1[A_records]
array d2[A_records]
j=0
stats $data using (j=j+1, d1[j] = $2, d2[j] = $2+$3) nooutput
set style arrow 1 nohead lt 1 lc black dt 2
set for [j=2:A_records] arrow from (j-2+bw/2),d1[j-1] to (j-1-bw/2),d1[j] as 1
set for [j=2:A_records] arrow from (j-2+bw/2),d2[j-1] to (j-1-bw/2),d2[j] as 1
plot $data \ using 2:xtic(1) with hist, '' \ using 3 with hist, '' \ using 4 with hist
This kind of plot can be constructed in gnuplot 6.1 using the newly introduced plot style
with hsteps
. However the available options are quite different fromwith histogram
.