文章出處

最近有個任務需要生成一個動態變化的圖,然后突然發現gnuplot竟然可以生成gif動畫,當真是應正了博客Gnuplot surprising的子標題:

I always tell myself: "Use your head, then you may find Gnuplot can plot graphics surprising you!"

一個簡單的例子

#繪制平移的正弦曲線
set term gif animate
set output "e1.gif"
set xrange [0:4*pi]
set yrange [-1:1]
do for [i=0:40]{
  plot sin(x+i*pi/40) lw 1.5 title sprintf("t=%i",i)
}
set output

效果:

注意:
貌似本用法只在gnuplot 4.6之后的版本中支持

設置圖片大小與動畫間隔

set term gif size 400,200 #設置圖片尺寸,注意該命令需要在下一條命令前,否則不會生成動畫
set term gif animate delay 5 #設置動畫圖片之間延時,單位ms
set output "e2.gif"
set xrange [0:4*pi]
set yrange [-1:1]
do for [i=0:40]{
  plot sin(x+i*pi/40) lw 1.5 title sprintf("t=%i",i)
}
set output

效果:

繪制自己實驗的模型表現變化動畫

我要觀察的是神經網絡模型隨著訓練回合的增長,與目標曲線擬合程度的變化動畫。

set term gif size 800,400
set term gif animate delay 20
set output "e3.gif"
set yrange [-50:300]
do for [i=1:50]{
  datafile=sprintf("data/0000017375.%03d.f0cmp.data",i) #我的數據地址
  set label 1 sprintf("epoch=%i",i) at 10,100 font "Arial, 25" #讓字體稍微大一點
  plot datafile u 1:2 title 'F0 Answer' w p, datafile u 1:3 title 'F0 Predict' w p pt 1,datafile u 1:4 title 'Word Duration' w p
}
set output

效果:


參考資源:

http://blog.sciencenet.cn/blog-373392-531682.html
http://gnuplot-surprising.blogspot.com/2012/04/new-version-of-gnuplot-makes-iterations.html


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 AutoPoster 的頭像
    AutoPoster

    互聯網 - 大數據

    AutoPoster 發表在 痞客邦 留言(0) 人氣()