LoginSignup
0
0

More than 5 years have passed since last update.

範囲外から範囲外へ動く場合の線の描画

Posted at

難儀した点

一定時間毎に gnuplotでY軸の上下幅固定でグラフを書いてる。
で、データが範囲外(上)から範囲外(下)になるものの移動の線が描画されないケースが出てきた。

手元にあるgnuplotのどんなバージョンでも、再現するのだから仕様なのだろう。

manは要領を得ないし、Google様は検索用語が悪いのか、中々正解に辿りつけない、、、

例えば、10が5回 -10が5回続くとかのケース

test.plt
#!/usr/bin/env gnuplot
set term dumb
set yrange [min:max]
plot '-'  u ($0):($1) notitle w l
10
10
10
10
10
-10
-10
-10
-10
-10
end

もちろん、-12〜12とかの範囲で描画すれば、きちんとラインは引かれる。

$ gnuplot -e 'min="-12";max="12"' test.plt


       +-------+------+-------+-------+------+-------+-------+------+-------+
       +       +      +       +       +      +       +       +      +       +
    10 ********************************                                    ++
       |                              *                                     |
       |                               *                                    |
       |                               *                                    |
     5 ++                               *                                  ++
       |                                *                                   |
       |                                 *                                  |
       |                                 *                                  |
     0 ++                                 *                                ++
       |                                  *                                 |
       |                                  *                                 |
       |                                   *                                |
    -5 ++                                  *                               ++
       |                                    *                               |
       |                                    *                               |
       |                                     *                              |
   -10 ++                                    ********************************
       +       +      +       +       +      +       +       +      +       +
       +-------+------+-------+-------+------+-------+-------+------+-------+
       0       1      2       3       4      5       6       7      8       9

しかし、-1〜1とかにすると、X=4〜5の斜線が引かれない、、、

$ gnuplot -e 'min="-1";max="1"' hoge.plt


      1 ++------+------+-------+------+-------+------+-------+------+------++
        +       +      +       +      +       +      +       +      +       +
        |                                                                   |
        |                                                                   |
        |                                                                   |
    0.5 ++                                                                 ++
        |                                                                   |
        |                                                                   |
        |                                                                   |
        |                                                                   |
      0 ++                                                                 ++
        |                                                                   |
        |                                                                   |
        |                                                                   |
        |                                                                   |
   -0.5 ++                                                                 ++
        |                                                                   |
        |                                                                   |
        |                                                                   |
        +       +      +       +      +       +      +       +      +       +
     -1 ++------+------+-------+------+-------+------+-------+------+------++
        0       1      2       3      4       5      6       7      8       9

"set clip two"

正解に辿りついてみたら、何の事はない。
一行set clip twoを足すだけ、、、

test2.plt
#!/usr/bin/env gnuplot
set term dumb
set clip two
set yrange [min:max]
plot '-'  u ($0):($1) notitle w l
10
10
10
10
10
-10
-10
-10
-10
-10
end
$ gnuplot -e 'min="-1";max="1"' test2.plt


      1 ++------+------+-------+------+---*---+------+-------+------+------++
        +       +      +       +      +   *   +      +       +      +       +
        |                                 *                                 |
        |                                 *                                 |
        |                                 *                                 |
    0.5 ++                                *                                ++
        |                                 *                                 |
        |                                 *                                 |
        |                                 *                                 |
        |                                 *                                 |
      0 ++                                *                                ++
        |                                 *                                 |
        |                                 *                                 |
        |                                 *                                 |
        |                                 *                                 |
   -0.5 ++                                *                                ++
        |                                 *                                 |
        |                                 *                                 |
        |                                 *                                 |
        +       +      +       +      +   *   +      +       +      +       +
     -1 ++------+------+-------+------+---*---+------+-------+------+------++
        0       1      2       3      4       5      6       7      8       9

アホくさ、、、

0
0
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
0
0