【问题标题】:Gnuplot plot only specified data setsGnuplot 仅绘制指定的数据集
【发布时间】:2013-04-14 00:36:01
【问题描述】:

我有以下结构的文件:

#title
month graph1 graph2 graph3
January 1 2 3
February 2 3 4

#title2
month graph1 graph2 graph3
January 1 2 3
February 2 3 4

我只想绘制以 title2 开头的数据集。

谢谢

【问题讨论】:

    标签: plot gnuplot


    【解决方案1】:

    使用足够新的 gnuplot 版本,您可以将名称指定为“索引”:

    plot 'datafilename' index 'title2'
    

    对于旧版本的 gnuplot,使用sed 仍然相对简单:

    plot "< sed '1,/#title2/d' datafile" using ...
    

    如果你想停止而不是绘制#title3数据:

    plot "< sed -n '/#title2/,/#title3/p' datafile" using ...
    

    演示:

    测试数据--

    #title
    month graph1 graph2 graph3
    January 1 2 3
    February 2 3 4
    
    #title2
    month graph1 graph2 graph3
    January 1 2 3
    February 2 3 4
    
    #title3
    January 5 6 3
    February 3 6 4.6
    

    测试脚本:

    plot "< sed '1,/#title2/d' test.dat" using 2:4 w lines,\
         "< sed -n '/#title2/,/#title3/p' test.dat" using 2:4 w p ps 5
    

    产生这个情节:

    请注意,只有第一行在末尾绘制了点。

    【讨论】:

    • 非常感谢。真的很有帮助。如果我有超过 1 个带有 title2 的块,我想绘制?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多