您好!我正在編寫一個腳本,用於繪製數值 (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" )}
)
)
);