0
votes

I would like to plot a bar chart or histogram like this in gnuplot. enter image description here

I tried set style histogram rowstacked which is a start but it adds the columns on top of each other while I need them overlapped. Next is the issue of transparent color shading.

Thanks for your feedback.

UPDATE: user8153 asked for additional data.

The set style histogram clustered gap 0.0 is doing the cluster mode of the histogram bars. If you blur the eye it sort-of shows what I want but with overlap and transparent shading.

enter image description here

The only other histogram modes given in the docs are rowstacked and columnstacked. I never got a plot out of columnstacked so I discarded it. Now rowstacked stacks the histogram bars.

enter image description here

The overlay appearance is there but it is wrong. I don't want the stacked appearance. The histograms have to overlay.

Code :

set boxwidth 1.0 absolute
set style fill solid 0.5 noborder 
set style data histogram
set style histogram clustered gap 0.0
#set style histogram rowstacked gap 0.0
set xtics in rotate by 90 offset first +0.5,0 right
set yrange [0:8000]
set xrange [90:180]

plot 'dat1.raw' using 3 lc rgb 'orange', \
     'dat2.raw' using 3  lc rgb 'blue', \
     'dat3.raw' using 3  lc rgb 'magenta'

Thanks for your feedback.

1
What does your data look like? I assume you can just plot two regular histograms in the same figure, using a terminal that supports transparency (I like pngcairo). - user8153

1 Answers

2
votes

Given a sample datafile test.dat

-10 4.5399929762484854e-05
-9 0.0003035391380788668
-8 0.001661557273173934
-7 0.007446583070924338
-6 0.02732372244729256
-5 0.0820849986238988
-4 0.20189651799465538
-3 0.4065696597405991
-2 0.6703200460356393
-1 0.9048374180359595
0 1.0
1 0.9048374180359595
2 0.6703200460356393
3 0.4065696597405991
4 0.20189651799465538
5 0.0820849986238988
6 0.02732372244729256
7 0.007446583070924338
8 0.001661557273173934
9 0.0003035391380788668
10 4.5399929762484854e-05

you can use the following commands

set style fill transparent solid 0.7
plot "test.dat" with boxes, \
     "test.dat" u ($1+4):2 with boxes

to get the following result (using the pngcairo terminal):

enter image description here