獲取當前顯示在樹狀圖上的行你好,
我想知道在縮放操作後是否有辦法知道哪些人當前顯示在樹狀圖上。
這是一個例子:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Birth Death Subset.jmp" );
Hierarchical Cluster(
Y( :birth, :death ),
Label( :country ),
Method( "Ward" ),
Standardize Data( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 4 ),
SendToReport(
Dispatch( {}, "Dendrogram", OutlineBox, {SetHorizontal( 1 )} ),
Dispatch(
{"Dendrogram"},
"2",
ScaleBox,
{Min( 18 ), Max( 31 ), Inc( 5 ), Minor Ticks( 0 )}
)
)
);我想獲得選定的 13 個國家/地區的列表。
我認為,一個好的解決方案是獲取最小值和最大值(18 和 31),但到目前為止我找不到如何提取它們......
在此先感謝您的幫助!
回复:獲取當前顯示在樹狀圖上的行你好@txnelson ,
我從未使用過此功能,但它確實擴大了 JMP 的可能性,太好了!
在我的情況下,我並不真的需要選擇行,而只是為了獲取 minOrder 和 maxOrder 值。 這就是為什麼我認為不會有提到的干擾問題@朱利安. 我需要測試一下:)
再次感謝你們兩位的幫助!
回复:獲取當前顯示在樹狀圖上的行啊,我們走了。 早該想到那個!
//編輯:添加該圖形腳本似乎會干擾雙擊以放大所選集群。 當然有一些方法可以讓它工作,但目前該按鈕似乎相當萬無一失,特別是如果您希望能夠在樹狀圖中選擇個人,然後將選擇重新建立到當前縮放。
回复:獲取當前顯示在樹狀圖上的行您可以附加圖形腳本
obj << 添加圖形腳本()
到樹狀圖框架框。每當對圖表執行某些操作時,它都會觸發。在添加的腳本中,您可以檢查 minOrder 或 MaxOrder 是否已更改。
回复:獲取當前顯示在樹狀圖上的行你好@anne_sa ,
這是個好主意,但我還沒有找到一個簡單的方法來實現它。 窗口底部的按鈕調用選擇怎麼樣?
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Birth Death Subset.jmp" );
hcPlatform = Hierarchical Cluster(
Y( :birth, :death ),
Label( :country ),
Method( "Ward" ),
Standardize Data( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 4 ),
SendToReport(
Dispatch( {}, "Dendrogram", OutlineBox, {SetHorizontal( 1 )} ),
Dispatch( {"Dendrogram"}, "2", ScaleBox, {Min( 18 ), Max( 31 ), Inc( 5 ), Minor Ticks( 0 )} )
)
);
//save the order displayed in the platform
displayOrd = hcPlatform << Save Display Order;
selectZoom = expr(
//get the script, which contains the Min() and Max() information
exprPlat = hcPlatform << Get Script;
//Extract the Min and Max. This is indexed in the reverse of the Display Order
//that is, the max value is the first in the order (as if it is an axis), so subtracting
//this value from the number of rows in the table brings things into alignment
minOrder = 1 + N Rows( dt ) - Arg( Extract Expr( exprPlat, Max( Wild() ) ) );
maxOrder = N Rows( dt ) - Arg( Extract Expr( exprPlat, Min( Wild() ) ) );
//select the rows in the table that meet the condition of being in the randge displayed
dt << Select Where( And( As Column( displayOrd ) >= minOrder, As Column( displayOrd ) <= maxOrder ) );
//get the matrix of row numbers for the selected rows, i.e., rows displayed in zoom
matchingRows = dt << get selected rows;
);
//add the button to the report
report(hcPlatform)<<APPEND></APPEND>
@朱利安
回复:獲取當前顯示在樹狀圖上的行你好@朱利安,
非常感謝您的快速回答,這正是我想要的!!!
我還有一個額外的小問題:有沒有一種方法可以檢測樹狀圖上是否進行了縮放操作? 也許是基於 <回复:獲取當前顯示在樹狀圖上的行做得很好。
回复:獲取當前顯示在樹狀圖上的行
你好@anne_sa ,
我不知道獲取這些行的直接方法,但由於 Min 和 Max 信息是平台腳本的一部分,並且因為我們可以保存樹狀圖中行的顯示順序,所以我們可以編寫自己的方式只需一點工作即可獲得結果。 它並不完全優雅,但這是我想出的一種方法:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Birth Death Subset.jmp" );
hcPlatform = Hierarchical Cluster(
Y( :birth, :death ),
Label( :country ),
Method( "Ward" ),
Standardize Data( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 4 ),
SendToReport(
Dispatch( {}, "Dendrogram", OutlineBox, {SetHorizontal( 1 )} ),
Dispatch( {"Dendrogram"}, "2", ScaleBox, {Min( 18 ), Max( 31 ), Inc( 5 ), Minor Ticks( 0 )} )
)
);
//save the order displayed in the platform
displayOrd = hcPlatform << Save Display Order;
//get the script, which contains the Min() and Max() information
exprPlat = hcPlatform << Get Script;
//Extract the Min and Max. This is indexed in the reverse of the Display Order
//that is, the max value is the first in the order (as if it is an axis), so subtracting
//this value from the number of rows in the table brings things into alignment
minOrder = 1 + N Rows( dt ) - Arg( Extract Expr( exprPlat, Max( Wild() ) ) );
maxOrder = N Rows( dt ) - Arg( Extract Expr( exprPlat, Min( Wild() ) ) );
//select the rows in the table that meet the condition of being in the randge displayed
dt << Select Where( And( As Column( displayOrd ) >= minOrder, As Column( displayOrd ) <= maxOrder ) );
//get the matrix of row numbers for the selected rows, i.e., rows displayed in zoom
matchingRows = dt << get selected rows;
我希望這有幫助!
@朱利安