你好,
我试图从折线图上的一个点绘制一条垂直和水平投影线,并找出同一图中第二条线的交点坐标(X 和 Y)。现在我一直通过可视化图表手动执行此操作,但我很好奇 Jmp 是否可以自动返回 X/Y 值。
在此示例中 - 我手动从紫色折线图中绘制了红线,并希望找到它与绿线和蓝线相交的位置

这是一个非常简单的脚本版本,它将采用示例数据表,通过每个实验的数据点进行样条拟合,然后允许您绘制从实验 2(蓝色)到实验 1(紫色)的线条,以及然后再次进行实验2。

运行脚本,然后在“Exter X value”输入框中输入一个值,然后点击“create line”
按钮。这是一个非常原始的脚本,仅适用于大约 2.5 到 4 的 X 值。但是,它会让您了解如何构建您想要的内容。
Names Default To Here( 1 );
// Create the sample data table
dt = New Table( "Sample",
Add Rows( 13 ),
New Column( "Experiment",
Character,
"Nominal",
Set Values(
{"exp1", "exp1", "exp1", "exp1", "exp2", "exp2", "exp2", "exp2", "exp3", "exp3", "exp3", "exp3", ""}
)
),
New Column( "V",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [0.55, 0.65, 0.85, 1.1, 0.55, 0.65, 0.85, 1.1, 0.55, 0.65, 0.85, 1.1, .] )
),
New Column( "X-axis",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [2.16, 2.79, 3.66, 4.19, 2.47, 3.13, 4.15, 4.72, 2.35, 2.95, 3.88, 4.36, 3] )
),
New Column( "Y-axis",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1.183, 2.12, 5.28, 11.2, 1.03, 1.85, 4.54, 9.25, 1.07, 1.93, 4.88, 9.74, .] )
)
);
nw = New Window( "Draw Lines",
hlb = H List Box(
// Generate the graph with the curves
Biv = dt << Bivariate( Y( :Name( "Y-axis" ) ), X( :Name( "X-axis" ) ) ),
V List Box(
Spacer Box( size( 1, 30 ) ),
H List Box( tbMain = Text Box( "Enter X value" ), neb = Number Edit Box() ),
Button Box( "Create Line",
start = neb << get;
// Create a list to hold the starting x,y pair
List1a = {};
List1a[1] = start;
// Find the Y value on experiment 2
fit2Y = Spline Eval( start, fitMat2 );
list1a[2] = fit2y;
// Create a list to hold the second x,y pair
list1b = {};
list1b[1] = start;
fit1Y = Spline Eval( start, fitMat1 );
list1b[2] = fit1Y;
// Create a list to hold the third x,y pair, which
// is the same as the second x,y pair
list2a = list1b;
// Create the 4th x,y pair
// to find the final X value, an iteration of the
// experiment 2 spline has to be done until it
// is larger than the experiment 1 Y value
list2b = {};
count = 0;
While( fit2Y < fit1Y | count > 300,
count++;
fit2Y = Spline Eval( start + (.01 * count), fitMat2 );
);
// set the final x,y values
list2b[1] = start + (.01 * count);
list2b[2] = fit1Y;
// Draw the lines
Report( biv )[FrameBox( 1 )] << add graphics script(
Pen Color( "red" );
Pen Size( 2 );
Line( list1a, list1b );
Line( list2a, list2b );
);
)
)
)
);
// add the spline fits and get the prediction matricies for each spline
biv << Fit Where( :Experiment == "exp1", Fit Spline( 0.001, {Line Color( "Purple" ), save coefficients} ) );
fitMat1 = Current Data Table() << get as matrix;
Close( Current Data Table(), nosave );
biv << Fit Where( :Experiment == "exp2", Fit Spline( 0.001, {Line Color( "Medium Dark Blue" ), save coefficients} ) );
fitMat2 = Current Data Table() << get as matrix;
Close( Current Data Table(), nosave );
biv << Fit Where(
:Experiment == "exp3",
Fit Spline( 0.001, {Line Color( "Medium Dark Green" ), save coefficients} )
);
fitMat3 = Current Data Table() << get as matrix;
Close( Current Data Table(), nosave );