【问题标题】:GNUPLOT heredoc; plot over xrange errorGNUPLOT heredoc;绘制 xrange 错误
【发布时间】:2014-06-25 22:47:37
【问题描述】:

我正在尝试在 (bash heredoc/script for) gnuplot 中进行分段线性拟合。我试过这个:

plot "datafile1" u 1:2:6:7:10:11 with xyerrorbars,\
     "datafile1" u 1:4:8:9:10:11 with xyerrorbars,\
     "datafile2" u 1:2:3 with xyerrorbars,\
     [xmin:xmax] f(x)

但它返回一个无效的表达式错误。任何想法为什么会失败?

注意 - fit [xmin:xmax] f(x) 不返回任何错误消息(所以我认为它有效)。

GNUPLOT 4.4.3

【问题讨论】:

    标签: gnuplot curve-fitting


    【解决方案1】:

    您只能在plot 命令的开头指定范围。此范围适用于此plot 命令的以下所有以逗号分隔的部分。所以你可以使用

    plot [xmin:xmax] f(x),\
         "datafile1" u 1:2:6:7:10:11 with xyerrorbars
    

    但这会将[xmin:xmax] 范围也应用于datafile1。如果您只想限制f(x)的范围,则必须定义一个超出所需范围的无效函数(1/0):

    plot "datafile1" u 1:2:6:7:10:11 with xyerrorbars,\
         "datafile1" u 1:4:8:9:10:11 with xyerrorbars,\
         "datafile2" u 1:2:3 with xyerrorbars,\
         (x > xmin && x < xmax) ? f(x) : 1/0
    

    请注意,您的原始命令将在即将推出的 gnuplot 5.0 版中运行

    【讨论】:

    • 谢谢。很抱歉唠叨,但这是否意味着这个答案 (stackoverflow.com/questions/17110310/…) 具有误导性?
    • 是的,那个答案是错误的,不知道为什么它被标记为接受。此处显示的语法仅适用于开发版本(即将发布的 5.0 版)。我会发表评论。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-31
    相关资源
    最近更新 更多