2017-03-16 83 views
2

我有一個包含X,Y分散數據的數據文件,我想以某種方式填充(圖案,實心透明,無論)這些點之外的空間。 enter image description hereGnuplot:如何填充數據集和圖之間的空間

我試圖與filledcurves關閉,但其填充內部,而不是外 enter image description here

有一種方法,以填補空間沒有數據點分成若干行和設定填充以上/軸下面?

謝謝

回答

2

難道是一種選擇使用Imagemagick處理這些情節?然後,你可以生成兩個圖像,一個透明度,後來將它們結合起來是這樣的:

# Generate some example data. 
set table "heatmap.dat" 
set isosamples 1000,100 
splot x 
unset table 

set table "ellipse.dat" 
set parametric 
plot 8*sin(t),5*cos(t) 
unset parametric 
unset table 

# Set this explicitly to let the borders of the two plots match exactly. 
set lmargin at screen 0.1 
set rmargin at screen 0.85 
set bmargin at screen 0.1 
set tmargin at screen 0.9 
set xrange [-10:10] 
set yrange [-10:10] 

# We are going to produce a png file 
set terminal pngcairo 

# First plot of the heatmap, this will be the background. 
set output "a.png" 
plot "heatmap.dat" with image 


# Plot again, we need the dummy heatmap for the color key. 
# We use the rectangle object for filling the area outside the ellipse. (Thanks @ewcz) 
# Later we interprete the color 444444 as transparent. 
set output "b.png" 
set object rectangle from -10,-10 to 10,10 fc rgb "#f0ddaa" fillstyle solid 1.0 
plot "heatmap.dat" using 1:2:(NaN) with image notitle,\ 
    "ellipse.dat" using 1:2 with filledcurves lc rgb "#444444" notitle 


# Overlay the pictures using imagemagick. The result is "result.png". 
system('convert b.png -transparent "#444444" c.png') 
system('composite -compose atop c.png a.png result.png') 

這是結果: section of a heatmap

making of

+0

好的技巧下的熱圖! :) – ewcz

1

爲了實現這樣的事情,你可以先創建一個矩形代表所需的背景,然後繪製與白色的它上面的數據:

set xr [-2:2] 
set yr [-2:2] 
set object rectangle from -2,-2 to 2,2 fc rgb "red" fillstyle solid 1.0 
plot 'test.dat' w filledcurves lc rgb "white" 
+0

這會工作,但問題是,我有在熱圖前填充空間,所以如果我用純色填充它,就不可能看到 –

相關問題