【问题标题】:plotting multiple graphs and animation from a data file in gnuplot从 gnuplot 中的数据文件绘制多个图形和动画
【发布时间】:2020-05-13 03:34:19
【问题描述】:

假设我有以下示例数据文件。

0   1   2
0   3   4   
0   1   9
0   9   2
0   19  0
0   6   1
0   11  0
1   3   2
1   3   4   
1   1   6
1   9   2
1   15  0
1   6   6
1   11  1
2   3   2
2   4   4   
2   1   6
2   9   6
2   15  0
2   6   6
2   11  1

第一列给出时间值。第二个给出 x 和第三列 y 的值。我希望在不同时间从这个数据文件中绘制 y 的图作为 x 的函数,

即,对于 t=0,我将使用 2:3 绘制线,直到 t=0 索引。然后我将对 t=1 处的变量做同样的事情。

最后,我想要一个 gif,即 y 与 x 图表如何随着时间推移而改变形状的动画。如何在 gnuplot 中做到这一点?

【问题讨论】:

    标签: animation plot gnuplot gif


    【解决方案1】:

    到目前为止,您尝试过什么? (检查help ternaryhelp gif

    您需要使用三元运算符过滤数据,然后创建动画。

    代码:

    ### plot filtered data and animate
    reset session
    
    $Data <<EOD
    0   1   2
    0   3   4   
    0   1   9
    0   9   2
    0   19  0
    0   6   1
    0   11  0
    1   3   2
    1   3   4   
    1   1   6
    1   9   2
    1   15  0
    1   6   6
    1   11  1
    2   3   2
    2   4   4   
    2   1   6
    2   9   6
    2   15  0
    2   6   
    2   11  1
    EOD
    
    set terminal gif animate delay 50 optimize
    set output "myAnimation.gif"
    
    set xrange[0:20]
    set yrange[0:10]
    do for [i=0:2] {
        plot $Data u 2:($1==i?$3:NaN) w lp pt 7 ti sprintf("Time: %g",i)
    }
    set output
    ### end of code
    

    结果:

    加法

    $1==i?$3:NaN在文字中的含义:

    如果第一列中的值等于i,则结果为第三列中的值,否则为NaN(“不是数字”)。

    【讨论】:

    • 你能给这些东西一个参考吗?就像“优化”、“延迟 50”、ti、pt 7、“$1==i?$3:NaN”等语法的使用......
    • 在 gnuplot 控制台中输入help &lt;keyword&gt;,例如optimize, delay --> help gif; $1==i?$3:NaN --> help ternary;而tititle的缩写,pt的缩写。对于pointtype。我无法在此处复制完整的 gnuplot 手册。检查这个:gnuplot.sourceforge.net/documentation.html
    猜你喜欢
    • 2022-10-23
    • 1970-01-01
    • 2012-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-08
    • 1970-01-01
    相关资源
    最近更新 更多