大家好,
我使用 JMP15 已經一年了,但我才剛開始對腳本感興趣。
我想編寫一個腳本來基於表格在圖表中顯示參考線。
我有 2 個表:資料(我在其上運行腳本,以繪製 value=f(time))和日期,其中包含一列,其中的日期對應於我希望在圖表中顯示的參考線。
這些表格附在我的貼文中。
這是我目前的腳本,根據表格日期的第一個元素(列日期)顯示一條參考線。
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 );
);