从轴到特定值的参考线我正在尝试编写一个图表,该图表显示软曲线上 x 轴上某个指定值在 y 轴上的预测值。 我已经设法提取预测公式并获得相关值来定义参考线。 然而,为了有效地传达这一点,我希望参考线停在曲线处,并且最好是虚线。 上图是我能够使用 jsl 脚本编写的图像。 下面是我想要结束的地方。
谢谢!


回复:从轴到特定值的参考线这看起来真的很酷,但可能也有点超出我目前的理解水平。 我将尝试按照您的示例进行工作,并希望在此过程中学到很多东西!
回复:从轴到特定值的参考线非常感谢,这正是我一直在寻找的!
回复:从轴到特定值的参考线下面的代码应该允许您动态分析任何仅涉及一个输入的已保存公式列。 在“大类”和四次模型的情况下,它给出:

它或多或少未经测试。
NamesDefaultToHere(1);
// Function to find leaves in formula that are columns in the table
// See: https://community.jmp.com/blogs/Uncharted/2015/04/03/head-arg-recurse-formula"
// Thanks to Craige Hales
findColumns =
Function( {frm, cols},
{h = Head( frm ), n = N Arg( frm ), i, result = {}}, // local variables
If( n == 0, // head node has no children, it is a leaf
If( Contains( cols, Name Expr( h ) ), // is the leaf in the list of columns?
Insert Into( result, Name Expr( h ) ); // yes -> add to result
)
,
For( i = 1, i <= n, i++, // not a leaf, get children's results
Insert Into( result, Recurse( Arg( frm, i ), cols ) )
)
);
result; // return the result
);
// Open a table to play with, and add a formula column to it
dt = Open("$SAMPLE_DATA/Big Class.jmp");
fCol = dt << New Column( "Predicted weight",
Formula(-127 + 4 * :height),
Set Property("Predicting", {:weight, Creator( "Bivariate" ), Model Name( "Polynomial Fit Degree=3" )})
);
// Recover the required information
f = fCol << getFormula;
xColList = findColumns(NameExpr(f), dt << getColumnNames);
yCol = fCol << getProperty("Predicting");
yCol = yCol[1];
// Subsequent code will only work with one x Column
xCol = Expr(xColList[1]);
for(c=1, c<=NItems(xColList), c++, Print(c); if(xColList[c] != xCol, Print("Only one x Column allowed."); Beep(); Throw()));
// Reparameterise the formula for later use in the 'GraphBox()'
SubstituteInto(f, xCol, Expr(x));
// Set the initial 'VLine()' value to the mean of the x values
xVals = xCol << getValues;
x = Mean(xVals);
// Get 'reasonable' ranges for the axes
xMin = Min(xVals);
xMax = Max(xVals);
yMin = Min(yCol << getValues);
yMax = Max(yCol << getValues);
// Get the names of the columns involved
xColName = xCol << getName;
yColName = yCol << getName;
// Plot the graph
NewWindow("Function Profile",
gb = GraphBox("Simple Profiler", XScale(xMin, xMax), YScale(yMin, yMax), XName(xColName), yName(yColName),
// Plot the function
PenColor("Red"); YFunction(f, x);
// Handle to drag the 'VLine()' and update display
Handle(x, yMin + (yMax-yMin)/10, gb << reShow, Empty());
// Get the function value for the current x value
yy = Eval(Substitute(NameExpr(f), Expr(x), x));
// Plot the lines at the new places
PenColor("Blue"); LineStyle("Dotted");
VLine(x, yMin, yy);
HLine(xMin, x, yy);
);
);回复:从轴到特定值的参考线添加到@迈克D_安德森,我发现开发将图形添加到平台中的图表的代码最简单的方法是右键单击相关图形,然后选择“自定义”。这允许人们实时修改并添加到图表中。然后我只需单击“+”并添加一个新段

使用模板或示例,或使用脚本编辑器的“图形类别”

人们可以摆弄显示器,直到得到他们想要的东西为止。

您可以转到红色三角形并保存脚本

这将为您提供一个示例脚本,您可以修改该脚本以使该脚本通用
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
Bivariate(
Y( :height ),
X( :age ),
Fit Polynomial( 2, {Line Color( {213, 72, 87} )} ),
SendToReport(
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Add Graphics Script(
2,
Description( "Script" ),
Line Style( dashed );
Line( [0, 13.35, 13.35], [62, 62, 50] );
), Grid Line Order( 1 ), Reference Line Order( 3 )}
)
)
);
回复:从轴到特定值的参考线不要使用轴上的两条参考线,而是尝试使用图形脚本在图形框中绘制一个矩形:
Names Default To Here( 1 );
New Window( "Example",
Graph Box(
// line color
Pen Color( "Green" );
// line width
Pen Size( 2 );
// line style (dashed)
Line Style (2);
Fill Color( "Red" );
// filled rectangle
Rect( 15, 75, 65, 55, 1 );
// unfilled rectangle (reference lines)
Rect( -1, 80, 70, -1 );
)
);
中号