3
votes

I'm trying to superimpose two histograms and I need the second one (blue in the image) to be transparent so the one below it can be seen:

enter image description here

This is the code I'm using:

#!/bin/bash
gnuplot << EOF

set term postscript portrait color enhanced 
set output 'test.ps'
set size ratio 1
set multiplot
set size 0.5,0.5

n=20    #number of intervals
max=1.0 #max value
min=0.0    #min value
width=(max-min)/n        #interval width
hist(x,width)=width*floor(x/width)+width/2.0

set boxwidth width*0.9
set xrange [0:1]
plot "/path_to_file" u (hist(\$1,width)):(1.0) smooth freq w boxes lc rgb "black" lt 1 lw 0.5 notitle fs solid 0.5, \
"/path_to_file" u (hist(\$2,width)):(1.0) smooth freq w boxes  notitle fs transparent pattern 4 noborder lc rgb "blue" lt 1 lw 0.5

EOF

Here's a file that can be used with the above code: http://pastebin.com/5qpFHgtZ

1
haha sorry for that. Removed the awk bit since it wasn't really necessary and added a data file. - Gabriel
I think you lost a plot in your script. I'll give this a shot and see what I can do with it... - mgilson
Yes I did, I'll correct it now. - Gabriel

1 Answers

2
votes

When I change the terminal to png (or pdf or pdfcairo) (e.g set term png enhanced), I get a plot which looks correct.

However, gnuplot seems to think that postscript should create a transparent plot (see table below, taken from help transparent). So, my diagnosis is that it is either a bug in gnuplot, or a bug in the documentation.

   terminal   solid pattern    pm3d
   --------------------------------
   gif           no     yes      no
   jpeg         yes      no     yes
   pdf          yes     yes     yes
   png    TrueColor   index     yes
   post          no     yes      no
   svg          yes      no     yes
   win          yes     yes     yes
   wxt          yes     yes     yes
   x11           no     yes      no