Gnuplot将多个数据文件的域限制在一个绘图上
问题描述:
我使用我写的.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
命令,但是这不起作用。
答
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
这工作得很好!我的所有山峰都有清晰的情节。我应该从哪里开始,以便能够拟合指数衰减函数以适应这些峰值? (它应该看起来像一个包含所有数据点的包络线 –
您必须将所有的衰变曲线中的点放在一个文件(或内联数据集)中以使用“拟合”。单线:设置表$ T1data; replot ; unset table; fit I-2 * I * exp(-x/T1)$ T1data us 1:2 noerr via I,T1'(我认为反转恢复;-))您可能想要调整左右极限每个回声使得'x()'只返回一个值。 – Karl
这是倒转恢复!谢谢。我仍然无法使用gnuplot。我可能会切换回数学! –