2017-05-18 22 views
3

我想要繪製兩個2D標量,一個爲熱圖和一個爲疊加輪廓,使用下面的代碼:產生gnuplot的:輪廓和熱圖來自同一splot兩個不同的文件

set contour base 
set cntrparam levels incremental 0,0.25,1.25 
unset surface 
set table cont2.dat 
splot 'vr245.gnu' 
unset table 
reset 
set xrange [1:215] 
set yrange [0:3.1415925025940E+00] 
set cbrange [7:17] 
unset key 
set view map 
set palette rgbformulae 33,13,10 
splot 'f_aveFe_245.gnu' u 1:2:3 with pm3d, "cont2.dat" u 1:2:3 w l 

結果由gnuplot Result produced by gnuplot

正如你所看到的輪廓在左邊有文物。我該如何解決這個問題?謝謝!

Input files are here.

回答

1

這其實挺有意思的。這個問題似乎出現在對應於1.25的水平的特定輪廓上。我想我把這個問題分離出來了。

讓我們假設我們有一個簡單的數據文件作爲

215 2.55865 1.25 
212.185 2.56004 1.25 
215 2.87839 1.25 

215 0.2632 1.25 
212.185 0.252052 1.25 
215 0.582938 1.25 

目前,gnuplot的命令(S)

unset key 
set view map 

set xr [212:215.5] 
set yr [0:3] 

set xtics nomirror 
set ytics nomirror 

splot \ 
    'file.dat' w lp, \ 
    '' u 1:2:3:(sprintf("%d", $0)) w labels offset char 0, char -0.5 

產生 enter image description here

有趣的是,還分1和4加入。如果數據文件被修改爲

215 2.55865 1.25 
212.185 2.56004 1.25 
215 2.87839 1.25 
# 
215 0.2632 1.25 
212.185 0.252052 1.25 
215 0.582938 1.25 

gnuplot的預期僅連接點2和3: enter image description here

什麼似乎幫助這裏是複製的空行,也就是說,這個文件

215 2.55865 1.25 
212.185 2.56004 1.25 
215 2.87839 1.25 


215 0.2632 1.25 
212.185 0.252052 1.25 
215 0.582938 1.25 

給出確實斷開組件: enter image description here

到App LY這在腳本中,人們可能會援引例如gawk和僅需要複製文件中的所有空行與計算出的輪廓:通過使用plot

set terminal pngcairo 
set output 'fig.png' 

set contour base 
set cntrparam levels incremental 0,0.25,1.25 
unset surface 
set table 'cont2.dat' 
splot 'vr245.gnu' 
unset table 
reset 

set xrange [1:215] 
set yrange [0:pi] 
set cbrange [7:17] 
unset key 
set view map 
set palette rgbformulae 33,13,10 
splot \ 
    'f_aveFe_245.gnu' u 1:2:3 with pm3d, \ 
    '<gawk "NF==0{print;} {print;}" cont2.dat' u 1:2:3 w l 

這給 enter image description here

或者,你可能會解決這個問題繪製的輪廓,而不是splot

set terminal pngcairo 
set output 'fig.png' 

set contour base 
set cntrparam levels incremental 0,0.25,1.25 
unset surface 
set table 'cont2.dat' 
splot 'vr245.gnu' 
unset table 
reset 

set xrange [1:215] 
set yrange [0:pi] 
set cbrange [7:17] 
unset key 
set view map 
set palette rgbformulae 33,13,10 

set multiplot 

set tmargin at screen 0.9 
set lmargin at screen 0.1 
set rmargin at screen 0.8 
set bmargin at screen 0.1 

splot \ 
    'f_aveFe_245.gnu' u 1:2:3 with pm3d 

unset xtics 
unset ytics 
unset border 
unset key 
plot \ 
    'cont2.dat' w l 
1

可以有選擇地接通或斷開所述表面的輪廓和繪圖爲個人情節在一個單一的污點。定義腳本都pm3dcontours,停用第一和表面輪廓的

reset 
set contour base 
set cntrparam levels incremental 0,0.25,1.25 
set cntrlabel onecolor 
set autoscale xfix 
set autoscale yfix 
set cbrange [7:17] 
unset key 
set view map 
set palette rgbformulae 33,13,10 
splot 'f_aveFe_245.gnu' u 1:2:3 with pm3d nocontour, \ 
    'vr245.gnu' u 1:2:3 w l lc rgb "black" nosurface 

enter image description here

相關問題