LoginSignup
2
1

More than 5 years have passed since last update.

gnuplotのforループ 列を使った演算

Posted at

gnuplot 4.6以降で効率よくプロットするtip

ーーー結論ーーー
plot for [col=1:5] 'band.dat' using 1:(column(col)-1.121995) w l lw 2 lc rgb "#ff0000" notitle
ーーーーーーーー

以前は以下のようにいちいち書いててメンドくさかった。。

plot "band.dat" u 1:5 w l lw 2  lc rgb "#ff0000"  notitle , "band.dat" u 1:6 w l lw 2 lc rgb "#ff    0000" notitle, "band.dat" u 1:7 w l  lw 2 lc rgb "#ff0000"  notitle 

バージョン4.6以降はfor loopでスッキリ

plot for [col=1:5] 'band.dat' using 1:col w l  lw 2 lc rgb "#ff0000" notitle

列の演算でusing 1:(col+1) だと上手くいかないので調べたところcolumn(col)と書けばよいみたい。

plot for [col=1:5] 'band.dat' using 1:(column(col)-1.121995) w l  lw 2 lc rgb "#ff0000" notitle

以上、今回の備忘録。

Ref.
https://stackoverflow.com/questions/25380929/loops-in-gnuplot-inside-the-plot-command

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1