GNUPLOTの第一歩

X軸やY軸が2系統あるグラフ

比較的新しい gnuplot (version 3.6以降?)では、Y軸の刻みを2通りに 刻めます。

      gnuplot> set y2tics
      gnuplot> set y2range [-5:15]
      gnuplot> plot sin(x),           cos(x) axes x1y2
      gnuplot> plot sin(x) axes x1y2, cos(x)

axesの引数には x1y1, x1y2, x2y1, x2y2 の何れかが指定できます。

set y2ticsの代わりにset x2ticsを指定すれば、X軸が2系統になります。

      gnuplot> set x2tics
      gnuplot> set x2range [-5:5]
      gnuplot> plot sin(x),           cos(x) axes x2y1
      gnuplot> plot sin(x) axes x2y1, cos(x)

もちろん、y2ticsとx2ticsは混在できます。

      gnuplot> set x2tics; set y2tics
      gnuplot> set x2range [-5:5]; set y2range [-5:5]
      gnuplot> plot sin(x) axes x1y1, cos(x) axes x2y2

なお、想像通りset xrangeやset yrangeを使って、x1やy1の範囲を変更 できます。これは2系統のX軸やY軸が不要の場合でも使えます。


GNUPLOTの第一歩
小栗栖 修
メールアドレス: ogurisu[AT]kanazawa-u.ac.jp ([AT]を@におきかえてください)