2015-06-27 92 views
1

我使用我寫的.plt文件訪問來自多個不同文件的數據。每個數據集只有一個特定的域是重要的。我試圖將每個數據集的特定域繪製到一個圖上。Gnuplot將多個數據文件的域限制在一個繪圖上

每個域中的數據對應一個峯值。我想繪製這些峯的每一個,然後將指數衰減函數擬合到峯。

這裏是我的陰謀文件中的代碼:

set xlabel "Time (ms)" 
set ylabel "voltage" 

set title "T1 time for Isopropyl Alcohol" 
dir='C:\Users\Daniel\Desktop\College\modern lab\gp501-win64-mingw\gnuplot\bin\data files\isoproply_alc_t1\' 
unset key 
set style data linespoints 
x(v, left, right) = (v >= left && v <= right ? v : 1/0) 
plot dir.'nmr-t1-isopropyl-dt10' using (x($0*0.01, 3, 7)):1, \ 
    dir.'nmr-t1-isopropyl-dt50' using (x($0*0.01, 20, 40)):1, \ 
    dir.'nmr-t1-isopropyl-dt100' using (x($0*0.01, 40, 60)):1, \ 
    dir.'nmr-t1-isopropyl-dt150' using (x($0*0.01, 70, 80)):1, \ 
    dir.'nmr-t1-isopropyl-dt200' using (x($0*0.01, 99, 101)):1, \ 
    dir.'nmr-t1-isopropyl-dt230' using (x($0*0.01, 114, 116)):1, \ 
    dir.'nmr-t1-isopropyl-dt250' using (x($0*0.01, 124, 126)):1, \ 
    dir.'nmr-t1-isopropyl-dt270' using (x($0*0.01, 134, 136)):1, \ 
    dir.'nmr-t1-isopropyl-dt290' using (x($0*0.01, 144, 146)):1, \ 
    dir.'nmr-t1-isopropyl-dt300' using (x($0*0.01, 149, 151)):1, \ 
    dir.'nmr-t1-isopropyl-dt320' using (x($0*0.01, 159, 161)):1, \ 
    dir.'nmr-t1-isopropyl-dt340' using (x($0*0.01, 169, 171)):1, \ 
    dir.'nmr-t1-isopropyl-dt360' using (x($0*0.01, 178, 183)):1, \ 
    dir.'nmr-t1-isopropyl-dt400' using (x($0*0.01, 198, 201)):1, \ 
    dir.'nmr-t1-isopropyl-dt430' using (x($0*0.01, 213, 217)):1, \ 
    dir.'nmr-t1-isopropyl-dt470' using (x($0*0.01, 233, 236)):1, \ 
    dir.'nmr-t1-isopropyl-dt580' using (x($0*0.01, 289, 291)):1, \ 
    dir.'nmr-t1-isopropyl-dt620' using (x($0*0.01, 309, 311)):1, \ 
    dir.'nmr-t1-isopropyl-dt650' using (x($0*0.01, 324, 326)):1, \ 
    dir.'nmr-t1-isopropyl-dt700' using (x($0*0.01, 348, 352)):1, \ 
    dir.'nmr-t1-isopropyl-dt750' using (x($0*0.01, 374, 376)):1, \ 
    dir.'nmr-t1-isopropyl-dt800' using (x($0*0.01, 399, 401)):1, \ 
    dir.'nmr-t1-isopropyl-dt850' using (x($0*0.01, 424, 426)):1, \ 
    dir.'nmr-t1-isopropyl-dt900.2' using (x($0*0.01, 449.5, 451)):1 

這給正確的域。

現在我想在y軸上翻轉數據點,通過一些任意的x值。我想讓他們消極。

我試過flipy命令,但是這不起作用。

回答

1

Gnuplot不支持在單個plot命令中爲每個數據文件指定單獨的範圍。這隻適用於功能。

你必須給想要的範圍,其無效的各個點的值1/0之外的所有點過濾在using語句中的數據:

left = 3 
right = 7 
plot 'file.dat' using ($0 > left && $0 < right ? $0 : 1/0):1 

爲了使命令其可讀性,你也可以把過濾功能。也有一些其他的可能性,以提高代碼的可讀性:

  • 定義一個變量dir包含路徑到您的文件。數據文件名,然後由.運營商利用這個變量,然後連接起來:

    dir = 'C:\my path\' 
    plot dir.'file.dat' ... 
    
  • 跳過鍵(傳奇),可以在全球範圍與unset key

  • 跳過您可以設置繪圖樣式將數據與全球文件set style data linespoints

所以,你的腳本可能看起來像

set xlabel "Time (ms)" 
set ylabel "voltage" 
set format y "%s" 

set title "T1 time for Isopropyl Alcohol" 
dir='C:\Users\Daniel\Desktop\College\modern lab\gp501-win64-mingw\gnuplot\bin\data files\isoproply_alc_t1\' 
unset key 
set style data linespoints 
x(v, left, right) = (v >= left && v <= right ? v : 1/0 
plot dir.'nmr-t1-isopropyl-dt10' using (x($0*0.01, 3, 7)):1, \ 
    dir.'nmr-t1-isopropyl-dt50' using (x($0*0.01, 20, 40)):1, \ 
    dir.'nmr-t1-isopropyl-dt100' using (x($0*0.01, 40, 60)):1, \ 
    dir.'nmr-t1-isopropyl-dt150' using (x($0*0.01, 70, 80)):1 
+0

這工作得很好!我的所有山峯都有清晰的情節。我應該從哪裏開始,以便能夠擬合指數衰減函數以適應這些峯值? (它應該看起來像一個包含所有數據點的包絡線 –

+0

您必須將所有的衰變曲線中的點放在一個文件(或內聯數據集)中以使用「擬合」。單線:設置表$ T1data; replot ; unset table; fit I-2 * I * exp(-x/T1)$ T1data us 1:2 noerr via I,T1'(我認爲反轉恢復;-))您可能想要調整左右極限每個回聲使得'x()'只返回一個值。 – Karl

+0

這是倒轉恢復!謝謝。我仍然無法使用gnuplot。我可能會切換回數學! –