您好!我正在编写一个脚本,用于绘制数值 (X) 与工具 (Y) 的关系图。该脚本包含数据表中给定的上下控制限,这些控制限会根据子组而变化,并在脚本运行时自动将这些控制限显示在图表上。此外,我还需要按“图层”分隔这些图表。以下是我目前的代码。我可以生成图表,但控制限线似乎无法显示。另外,第一个图表的点比其他图表小得多。我编写脚本的经验还比较少,所以非常感谢您的帮助!以下是我目前的代码。(JMP 版本:17.2)
Names Default To Here( 1 );
dt = Current Data Table();
xCol = Column( dt, "Tool" );
yCol = Column( dt, "Value" );
uclCol = Column( dt, "UCL" );
lclCol = Column( dt, "LCL" );
LayerCol = Column( dt, "Layer" );
gb = Graph Builder(
Size( 633, 6849 ),
Show Control Panel( 0 ),
Title Fill Color( "White" ),
Level Fill Color( "White" ),
Page Level Fill Color( "White" ),
Variables( X( :Tool ), Y( :Value ), Page( :Layer ) ),
Elements( Points( X, Y, Legend( 1 ) ) ),
Elements( Line( X( xCol ), Y( uclCol ), Legend( 2 ) ) ),
Elements( Line( X( xCol ), Y( lclCol ), Legend( 3 ) ) ),
SendToReport(
Dispatch( {}, "Graph", ScaleBox, {Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )} ),
Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 2 ), Line Width( 2 )} ),
)
);
rep = gb << Report();
fr = rep[FrameBox( 1 )];
leg = rep[LegendBox( 1 )];
leg = rep[Legend Box( 1 )];
Try( leg << Set Item Name( 1, "Value" ) );
Try( leg << Set Item Color( 1, "Steel Blue" ) );
Try( fr << Set Marker Size( 1, 3 ) );
Try( fr << Set Marker Style( 1, "FilledCircle" ) );
Try( leg << Set Item Name( 2, "UCL" ) );
Try( leg << Set Item Name( 3, "LCL" ) );
Try( leg << Set Item Color( 2, "Red" ) );
Try( leg << Set Item Color( 3, "Red" ) );
Try( leg << Set Item Line Style( 2, "Solid" ) );
Try( leg << Set Item Line Style( 3, "Solid" ) );
Try( fr << Set Line Width( 2, 2 ) ); // UCL
Try( fr << Set Line Width( 3, 2 ) ); // LCL
由 txnelson 编辑为 JSL 显示盒
如果您使用图形生成器的交互式功能生成所需的图形,则只需指定保存脚本,它就会生成一个复制该图形的脚本。
嗨,Jim,谢谢你的回复!我已经成功生成了图表,但我现在遇到的最大问题是,我仍然不知道如何在脚本中添加 UCL 和 LCL 参考线,以便脚本运行时,图表能够按层分隔,并且每个图表都包含其对应的 LCL 和 UCL 参考线。UCL 和 LCL 是我的数据表中的列,但我似乎找不到正确的引用方法。
嗨,吉姆,
附上数据表,以及我上面粘贴在表格脚本部分的原始脚本。
你只需要在 Y 轴上添加 UCL 和 LCL,然后添加一条线,并指定 Value 是点的唯一变量,LCL 和 UCL 是线的唯一变量。

Graph Builder(
Size( 633, 6849 ),
Show Control Panel( 0 ),
Title Fill Color( "White" ),
Level Fill Color( "White" ),
Page Level Fill Color( "White" ),
Variables(
X( :Tool ),
Y( :Value ),
Y( :UCL, Position( 1 ) ),
Y( :LCL, Position( 1 ) ),
Page( :Layer )
),
Elements(
Points( X, Y( 1 ), Legend( 1 ) ),
Line( X, Y( 2 ), Y( 3 ), Legend( 2 ) )
),
SendToReport(
Dispatch( {}, "Graph Builder", FrameBox,
{Marker Size( 2 ), Marker Drawing Mode( "Normal" )}
)
)
);