JMP 社区您好;
在我寻求自动化注释图形生成器绘图的一些更繁琐的任务时,我尝试使用以下脚本在数据组之间动态添加水平线段。 不幸的是,看起来我无法使用简单的 Expr () 后跟 Substitute () 和 Eval () 来完成此特定任务。 注意:我正在处理敏感数据,因此如有必要,我需要创建模拟 DATA 和 STAT 表。
Names Default to Here (1);
dt1 = Data Table ("DATA.JMP");
dt2 = Data Table ("STAT.JMP");
gbe = Expr (dt1 << Graph Builder(
Size( 699, 625 ),
Variables(
X( :R vs NR ),
Y( _YS_ ),
Color( :R vs NR )
),
Elements(
Points( X, Y, Legend( 6 ) ),
Box Plot( X, Y, Legend( 8 ), Outliers( 0 ) )
),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script(
2,
Description( "Script" ),
Pen Size (3);
// The following line of code return the error "Invalid Matrix Token"
Line ([0.2,0.8], [Y1, Y1]);
Text( Center Justified, {0.5, top1}, VAL1 );
// The following line of code return the error "Invalid Matrix Token"
Line ([0.2,1.8], [Y2, Y2]);
Text( Center Justified, {1.0, top2}, VAL2 );
// The following line of code return the error "Invalid Matrix Token"
Line ([1.2,1.8], [Y1, Y1]);
Text( Center Justified, {1.5, top1}, VAL3 );
), Grid Line Order( 1 ), Reference Line Order( 3 )}
)
)
)
);
For (i = 749, i <= 750, i++,
YCOL = Column (dt1, i);
PVAL1 = "p VAL = " || CHAR(format(Column (dt2, 2) [i-747],"PValue"));
PVAL2 = "p VAL = " || CHAR(format(Column (dt2, 3) [i-747],"PValue"));
PVAL3 = "p VAL = " || CHAR(format(Column (dt2, 4) [i-747],"PValue"));
data_topy1 = Col Quantile (YCOL, 0.99);
data_topy2 = Col Quantile (YCOL, 0.975);
gbx = Substitute(Name Expr (gbe),
Expr (_YS_), YCOL,
Expr (VAL1), PVAL1,
Expr (VAL2), PVAL2,
Expr (VAL3), PVAL3,
Expr (Y1), data_topy1,
Expr (Y2), data_topy2
);
gb = Eval (gbx);
gb << journal;
gb << close window;
);任何想法都会受到欢迎。
谢谢
您的解决方案对于这种情况来说是一个很好的解决方案,因为 HLine 和 VLine 是无限长的。 这是一个解释和一些替代方案。
方括号矩阵是编译时常量,不能使用变量。 我经常使用串联运算符来构建这样的小矩阵:
a = 17;
b = 23;
Show( a || b, a |/ b );
一个 || b = [17 23];
a |/ b = [17, 23];
您还可以使用矩阵():
matrix( {{a, b}, {a, a}} );[17 23, 17 17]
如果你的线需要限制在 0.2 和 1.8 之间,你可以使用不同形式的线,它采用列表而不是矩阵:
line( {x1,y1}, {x2,y2} )line 函数计算每个列表中的表达式。
而且,如果您需要以水平或垂直以外的某个角度无限长的线,您可以使用 YFunction():
YFunctionYFunctionY函数