2012-09-12 38 views
3

我試圖疊加兩個柱狀圖,我需要第二個(藍色圖像中)是透明的,所以它下面的一個可以看出:gnuplot的 - 設置透明直方圖

enter image description here

這是我使用的代碼:

#!/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 

下面是可以與上面的代碼中使用的文件:http://pastebin.com/5qpFHgtZ

+0

而'awk'並不奇怪; ^) – mgilson

+0

哈哈對不起。刪除了'awk'位,因爲它不是真的必需的,並且添加了一個數據文件。 – Gabriel

+0

我認爲你在劇本中失去了一個「情節」。我給這個一杆,看看有什麼我可以用它做... – mgilson

回答

2

當我改變日Ë終端png(或pdfpdfcairo)(例如set term png enhanced),我得到一個曲線圖,看起來是正確的。

但是,gnuplot似乎認爲postscript應該創建一個透明的情節(見下表,取自help transparent)。所以,我的診斷是它是gnuplot中的錯誤,或者是文檔中的錯誤。

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 
+0

你是正確的,它不以'png'終端工作。我怎樣才能從這個終端獲得高質量的輸出?我想我會使用它,因爲'postscript'不會處理透明膠片。 – Gabriel

+1

@Gabriel - p.s.我提起[錯誤報告(https://sourceforge.net/tracker/?func=detail&aid=3567035&group_id=2055&atid=102055) – mgilson

+1

@Gabriel - I也嘗試過在'pdf'和'pdfcairo'終端和它工作。如果您安裝了任何一個終端,它們可能會更「高質量」。 – mgilson