大家好,
我使用 JMP15 已有 1 年,但我才刚刚开始对脚本感兴趣。
我想编写一个脚本,根据表格在图形中显示参考线。
我有 2 个表:数据(我在其上运行脚本,绘制值=f(时间))和日期,其中包含一列,其中的日期对应于我想要在图表中显示的参考线。
这些表格已附加到我的帖子中。
这是我当前的脚本,根据表日期的第一个元素(列日期)显示一条参考线。
ref1 = dates:name( "date" )[1];
Graph Builder(
Variables( X( :time ), Y( :value ),Page(:cat) ),
Elements( Points( X, Y, Legend( 4 ), Summary Statistic( "Mean" ) ) ),
SendToReport( Dispatch( {}, "time", ScaleBox( 2 ), {Add Ref Line( ref1, "Dotted", "Red", "", 2 )} ) )
);我想创建一个“For”循环来为表“日期”的每个值自动创建参考线。
以下是我尝试过的:
ref1 = dates:name( "date" )[1];
Graph Builder(
Variables( X( :time ), Y( :value ),Page(:cat) ),
Elements( Points( X, Y, Legend( 4 ), Summary Statistic( "Mean" ) ) ),
SendToReport( Dispatch( {}, "time", ScaleBox( 2 ),
{
For( i = 1, i <= N row( dates), i++,
f = dates [ i ];
Add Ref Line( f, "Dotted", "Blue", "", 2 )
);
})
);但是当我运行脚本时,没有出现参考线。
我该如何解决这个问题?
最后一个问题:如果我不在图形变量中添加“Page(:cat)”,则不会出现参考线...
感谢您的帮助 !!
欢迎来到讨论社区!
这是添加参考线的一种方法

有关如何使用显示树来操作 JMP 输出的文档可在脚本索引中找到。
Names Default To Here( 1 );
dt = Data Table( "data" );
dates = Data Table( "dates" );
ref1 = dates:name( "date" )[1];
gb = Graph Builder(
Variables( X( :time ), Y( :value ), Page( :cat ) ),
Elements( Points( X, Y, Legend( 4 ), Summary Statistic( "Mean" ) ) ),
SendToReport(
Dispatch( {}, "time", ScaleBox( 2 ), {Add Ref Line( ref1, "Dotted", "Red", "", 2 )} )
)
);
// Add reference lines
For( i = 1, i <= N Rows( dates ), i++,
// Add for Cat = B
(Report( gb )[axisbox( 1 )]) << add ref line( dates:date[i], "Dotted", "Blue", "", 2 );
// Add for Cat = C
(Report( gb )[axisbox( 3 )]) << add ref line( dates:date[i], "Dotted", "Blue", "", 2 );
);