土曜日, 10月 19, 2013

位相進行アニメ2 : phase marching plot vol2


グラフ内に,時刻(x 座標に相当)の文字列を差し込む.
gnuplot での 文字列差し込みは,このページを参考に.

------------------

#!/bin/bash

echo "gnuplot_anim.sh"

### parameter for plot
Xmin="-0.25*pi"
Xmax="4*pi+0.25*pi"
Ymin="-1.2"
Ymax=" 1.2"

### parameter for sliding point
Xinit=0.0
#Xterm=6.28
Xterm=12.56
nDiv=40


##-----
dX=`echo "scale=5; (${Xterm} - ${Xinit}) / ${nDiv}" | bc`
echo "dX:"${dX}

X=0.0


for i in `seq -w 1 $((nDiv+1)) ` ; do
    Y=`echo "scale=5; s(${X})" | bc -l`
    echo "i: "${i}" X: "${X}" Y: "${Y}
    echo  ${X}" "${Y}   > "./point.tmp"

    CurrentTime=`echo Time=${X}`

    gnuplot << EOF
    set out "output${i}.gif"
    set term gif
    set grid
    set xrange [$Xmin:$Xmax]
    set yrange [$Ymin:$Ymax]
    set title "$TITLE"
    set label 1 at screen 0.15    ,0.15 "$CurrentTime"
    set pointsize 4
    plot sin(x), "point.tmp" w points pointtype 7  title "current point"
EOF

#    plot sin(x), "point.tmp" w points pointtype 6  title "current point"

    X=`echo "scale=5; (${X} + ${dX})" | bc`
done


convert -delay 10 -loop 0 ./output*.gif  animation.gif






 ------------------


結果的に,以下のように.

左下に時刻表示をつくれました  m(_ _)m

0 件のコメント: