2012-12-12 82 views
2

與gnuplot的產生如下因素圖表:enter image description heregnuplot的不重疊線

它顯示了圖5(但也可以是更多或更少的)波。不過,我需要的是顯示每一波分開,像這樣(我與GIMP):

enter image description here

有沒有辦法用gnuplot的做到這一點?我還需要每一波都是不同的顏色,就像我現在所擁有的那樣。

這裏使用的gnuplot腳本:http://pastebin.com/vAD2syTS

這裏是Python腳本,GNUPLOT腳本用來解決我的數據:http://pastebin.com/WEncNjDA

下面是數據:http://pastebin.com/ewBpvHWM

這裏是蟒蛇後的數據腳本修復它:http://pastebin.com/cgimMyr9

+0

這是一個棘手的一個,如果我們不能假設你知道提前的陰謀的數量... – mgilson

+0

@mgilson我可以腳本來找到這個或類似 –

+0

我今天休息,但看到我的答案...無論如何,它應該給你一些東西來玩。 – mgilson

回答

5

我有一些有趣的這一個。我的策略包括繪製具有略微不同設置的第一個,最後一個和中間的地塊,以使邊界排列。我還定義了一些函數來確保所有的繪圖顏色確實會有所不同,除非您有大約1600萬的數據集要繪製。

### indices: change this parameter to equal the number of data sets to be plotted 
indices = 8 
# h: height of output in pixels 
h = 150.0*indices 
# d: top and bottom margin in pixels 
d = 75.0 

### define functions to help set top/bottom margins 
top(i,n,h,d) = 1.0 - (d+(h-2*d)*(i-1)/n)/h 
bot(i,n,h,d) = 1.0 - (d+(h-2*d)*i/n)/h 

### define some fun RGB code converter functions 

# round: crude rounding function (gnuplot doesn't have this?) 
# assumes a float, returns an int 
round(x) = x-int(x)>=0.5?ceil(x):floor(x) 

# i2h: converts a (decimal) integer between 0 and 15 to hex. 
# returns a string, 0-F corresponding to 0-15 
i2h(i) = i==10?'A':i==11?'B':i==12?'C':i==13?'D':i==14?'E':i==15?'F':sprintf('%d',i) 

# i2r: converts an integer to an RGB code. 
# returns a string (RGB code) of length 6, 000000-FFFFFF corresponding to 0-16777215 
# changing the last division to 15 instead of 16 prevents colors being too faint 
i2r5(i) = i2h(i/(15**5)) 
i2r4(i) = i2h(i%(16**5)/(15**4)) 
i2r3(i) = i2h(i%(16**5)%(16**4)/(15**3)) 
i2r2(i) = i2h(i%(16**5)%(16**4)%(16**3)/(15**2)) 
i2r1(i) = i2h(i%(16**5)%(16**4)%(16**3)%(16**2)/(15**1)) 
i2r0(i) = i2h(i%(16**5)%(16**4)%(16**3)%(16**2)%(16**1)) 
i2r(i) = i2r5(i).i2r4(i).i2r3(i).i2r2(i).i2r1(i).i2r0(i) 

# rgb_iter: returns the i-th of n RGB codes, evenly spaced across the spectrum 
rgb_iter(i, n) = '#'.i2r(round((i-1)*(16777215.0/(n-1)))) 

### first set up some basic plot parameters 
set term png enhanced size 800,h font 'Courier-Bold,14' 
set output 'waves.png' 

set title 'Wave propagation by geophones' 
set ylabel 'Wave' 

set xrange [1400:] 
set yrange [-0.15:0.15] 
set ytics ('-0.1' -0.1, '0.0' 0.0, '0.1' 0.1) 

set key out right 

### now make plots 
set multiplot layout indices,1 

### first plot 
set border 14 
set tmargin at screen top(1,indices,h,d) 
set bmargin at screen bot(1,indices,h,d) 
unset xtics 
plot 'temp.dat' index 0 w lines lw 3 lc rgb rgb_iter(1,indices) title 'Geophone 1' 
unset title 

### intermediate plots 
set border 10 
unset xlabel 
do for [i=1:indices-2] { 
set tmargin at screen top(i+1,indices,h,d) 
set bmargin at screen bot(i+1,indices,h,d) 
plot 'temp.dat' index i w lines lw 3 lc rgb rgb_iter(i+1,indices) title sprintf('Geophone %d', i + 1) 
} 

### last plot 
set border 11 
set tmargin at screen top(indices,indices,h,d) 
set bmargin at screen bot(indices,indices,h,d) 
set xtics nomirror 
set xlabel 'Iterations' 
plot 'temp.dat' index (indices-1) w lines lw 3 lc rgb rgb_iter(indices,indices) title sprintf('Geophone %d', indices) 

unset multiplot 

你的樣本數據集的輸出是這樣的: enter image description here

頂部的大小/底部的曲線不相當完美,並作爲mgilson說,它可能需要一些擺弄與set xmargin at screen ...命令使所有繪圖大小相等。

(如果沒有其他的那些內部 - > RGB轉換器可以很方便專業應用;我也有功能從RGB碼去整數)。

編輯:我更新腳本,以便所有的地塊將有相同的高度。

+0

爲什麼第一張和最後一張圖比其他圖小?我的意思是,它們的高度更小 –

+1

當使用'set multiplot layout X,1'命令時,每個繪圖獲得輸出文件垂直區域的1/X,默認情況下該空間的一部分用於邊距/標籤。頂部和底部的地塊較短,因爲它們不佔據整個地塊面積。對於中間的地塊,bmargin和tmargin設置爲0,因此它們佔據正好1 /指標的垂直區域。頂部和底部的圖表具有非零的邊界以容納標題和xlabel。 – andyras

+0

我知道我沒有問過這個問題,但是我應該在哪裏看這張圖向右旋轉90度? –

5

如果您知道提前的圖塊數(gnuplot 4.6):

NUM_PLOTS = 6 
set multiplot layout NUM_PLOTS,1 
do for [i=1:NUM_PLOTS]{ 
    plot 'temp.dat' index i w lines lw 3 title sprintf('Geophone %d', i + 1) 
} 
unset multiplot 

如果你真的想獲得幻想,以確保您的邊框和軸排隊,你可以使用的set lmargin at screen ...set rmargin at screen ...set tmargin at screen ...set bmargin at screen ...組合,其中...iNUM_PLOTS一些功能,雖然可能在某個恆定的位置設置lmarginrmargin就足夠了(如果不需要共享座標軸,gnuplot應該自上而下地對齊)。

set border 10將刪除頂部和底部的邊界線,如果你真的想這樣做,但可能沒有必要。

我建議是這樣的:

NUM_PLOTS = 6 
set multiplot layout NUM_PLOTS,1 
set lmargin at screen 0.1 
set rmargin at screen 0.9 
do for [i=1:NUM_PLOTS]{ 
    plot 'temp.dat' index i w lines lw 3 title sprintf('Geophone %d', i + 1) 
} 
unset multiplot 
+0

這很棒,但是它不斷重複標題,X軸標籤和X軸測量點。有沒有辦法將標題保留在第一個圖中,並在最後一個圖中保留X軸標籤和測量點? –