Gnuplot:多个" for"循环导致绘图成倍增加

时间:2015-07-09 18:46:57

标签: loops gnuplot

我试图在一张图上绘制多个XRD图案,它们之间有垂直偏移。文件名为E65.xy,例如

目前,这有效:

reset 
set xlabel "2 Theta"
set ylabel "Intensity"
set xrange [5:60]
set key outside right
set border 3
set xtics nomirror
set ytics nomirror
set terminal pdf color font 'times new roman,17'
set output "XRD_E65.pdf"
offset = 400
plot 'E58.xy' using 1:($2 + offset*5)   with lines ls 1 lc 1 title "E58 XRD"    , \
    'E59.xy' using 1:($2 + offset*4)    with lines ls 1 lc 2 title "E59 XRD"    , \
    'E61.xy' using 1:($2 + offset*3)    with lines ls 1 lc 3 title "E61 XRD"    , \
    'E62.xy' using 1:($2 + offset*2)    with lines ls 1 lc 4 title "E62 XRD"    , \
    'E64.xy' using 1:($2 + offset*1)    with lines ls 1 lc 5 title "E64 XRD"    , \
    'E65.xy' using 1:($2 + offset*0)    with lines ls 1 lc 6 title "E65 XRD"    

我有很多情节,所以我试图使用循环。我设法做到了这一点:

offset = 400
explist = "58 59 61 62 64 65"
plot for [exp in explist] "E".exp.".xy" using 1:($2 + offset * (count) ) with lines title "E".exp

将所有六种图案叠加在一起。我一直想在第一个for [count=1:6]参数后添加for"但是当我这样做时,我会得到36个地块,(6组地块偏移400)。

我想我明白为什么会发生这种情况,但我无法找到解决问题的方法。

1 个答案:

答案 0 :(得分:0)

通过添加for [count=1:6],您实际上正在创建一个嵌套循环,从而绘制偏移值和exp值的所有可能组合。

您应该考虑以下替代方案:

offsetlist = "5 4 3 2 1 0"
explist = "58 59 61 62 64 65"
plot for [i=1:6] "E".word(explist, i).".xy" using 1:($2 + word(offsetlist, i)) w l title "E".word(explist, i)