你好,
一种可能的低技术解决方案是在数据表的单独列中计算参考曲线,然后将其与其余数据一起绘制。
最好的,
TS
你好,
右键单击图形,从上下文菜单中选择“自定义”,单击“+”图标。 从这里您可以使用 Y 函数 ( ) 函数添加脚本,该函数有 2 个参数:一个表达式(函数)和域变量(此处为 x)。
单击确定,您就完成了。

这也很容易通过使用 Y 函数 ( ) 函数编写脚本来实现。 这里,绘制了对应于系数 [2, 3, -5] 的 y = 2x^2 + 3x -5。 我在这里使用了 Horner 的规则,因为它使下一个插图中的事情变得更容易。
dt = astable(J(40,2,randominteger(-20,20)));
gb = dt << Graph Builder( Variables( X( :Col2 ), Y( :Col1 ) ), Elements( Points( X, Y, Legend( 3 ) ) ) );
report(gb)[framebox(1)] << add graphics script ( Y Function( (2 * x + 3) * x - 5, x ) );
一个问题是系数可能在运行时确定,可能不是整数,并且多项式的次数可能是未知的。 在这种情况下,类似以下的内容将起作用:
dt = astable(J(40,2,randominteger(-20,20)));
gb = dt << Graph Builder(
Variables( X( :Col2 ), Y( :Col1 ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
);
// get random uniform coefficient matrix
coef = J(5, 1, randomuniform());
// build an expression using Horner's rule:
for each ( {v, i }, coef,// i = 1; v = coef[i];
if (i > 1,
fctExp = insert ( insert ( expr ( multiply ( ) ), nameExpr ( fctExp ) ), expr ( x ) );
,
fctExp = expr ( 0 );
);
fctExp = insert ( insert ( expr( add ( ) ), nameexpr( fctExp ) ), v );
);
// substitute into a graph script expressison and evaluate
graphAdd = expr (
report(gb)[framebox(1)] << add graphics script ( Y Function( _EXPRESSION_ , x ) )
);
eval ( substitute ( nameexpr(graphAdd), expr( _EXPRESSION_ ), nameexpr ( fctExp ) ) );
//show the expression in the log
show ( fctExp )

您最初关于通过自定义功能添加脚本的建议奏效了。 谢谢你!
你好。
我使用 Fit Y by X 绘制数据。
我想绘制一个已知的二次方程作为参考线(而不是将其拟合到显示的数据)。 我可以看到如何使用“Fit Special”、“线性”进行线性拟合,然后将截距和斜率限制为任何值,但是当从下拉框中选择二次(或更高阶)时,它不会为您提供输入额外系数进行约束的地方。
我可以通过脚本来完成吗?如果是的话,格式是什么?
非常感谢