Gnuplot:多个 "for" 循环导致绘图成倍增加
Gnuplot: Multiple "for" loops cause plots to multiply
我试图在一张图上绘制多个 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:( + offset*5) with lines ls 1 lc 1 title "E58 XRD" , \
'E59.xy' using 1:( + offset*4) with lines ls 1 lc 2 title "E59 XRD" , \
'E61.xy' using 1:( + offset*3) with lines ls 1 lc 3 title "E61 XRD" , \
'E62.xy' using 1:( + offset*2) with lines ls 1 lc 4 title "E62 XRD" , \
'E64.xy' using 1:( + offset*1) with lines ls 1 lc 5 title "E64 XRD" , \
'E65.xy' using 1:( + 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:( + offset * (count) ) with lines title "E".exp
将所有六个模式绘制在彼此之上。我一直想尝试在第一个 for
参数之后添加 for [count=1:6]
”,但是当我这样做时,我得到了 36 个图,(六组图偏移了 400)。
我想我明白为什么会发生这种情况,但我找不到修复它的解决方案。
通过添加 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:( + word(offsetlist, i)) w l title "E".word(explist, i)
我试图在一张图上绘制多个 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:( + offset*5) with lines ls 1 lc 1 title "E58 XRD" , \
'E59.xy' using 1:( + offset*4) with lines ls 1 lc 2 title "E59 XRD" , \
'E61.xy' using 1:( + offset*3) with lines ls 1 lc 3 title "E61 XRD" , \
'E62.xy' using 1:( + offset*2) with lines ls 1 lc 4 title "E62 XRD" , \
'E64.xy' using 1:( + offset*1) with lines ls 1 lc 5 title "E64 XRD" , \
'E65.xy' using 1:( + 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:( + offset * (count) ) with lines title "E".exp
将所有六个模式绘制在彼此之上。我一直想尝试在第一个 for
参数之后添加 for [count=1:6]
”,但是当我这样做时,我得到了 36 个图,(六组图偏移了 400)。
我想我明白为什么会发生这种情况,但我找不到修复它的解决方案。
通过添加 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:( + word(offsetlist, i)) w l title "E".word(explist, i)