您好JSL社區!
我使用了動態圖表圖例代碼 ,只需單擊1次即可自動更改圖例,因此效果很好。
但是,當它嘗試將本地數據過濾器包括在圖形中時,由於某些原因,單擊過濾器後,舊/舊圖例的邊框會重新出現。我發現了先前的討論基本上是相同的問題,但不幸的是,2014年以來的趨勢是獨白,當我嘗試執行他的所有TS步驟時,沒有一個適合我的情況。
圖例本身是正確的(數據顯示正確的顏色和標記),但是報表窗口正忙於處理所有先前的邊框。
我確實有一個解決方法,在此操作中,我只是添加了一個額外的按鈕,以在按下本地數據過濾器後刪除所有不必要的“傳說”,但是每次我點擊另一個過濾器時,它們都會重新出現。在本地數據過濾器中添加“刪除”按鈕的代碼時,我也沒有成功(因此,每當我使用過濾器功能時,它也會刪除所有多餘的圖例框)。
我只是想知道是否有一種方法可以刪除圖中以前圖例的“內存”。或在這種情況下可以使用的任何解決方法。
在此先感謝您的幫助和支持!!!
使用本地數據過濾器之前的圖形
使用本地數據過濾器後的圖形

您是否可以包括一個在一個示例JMP數據表上工作的腳本,該腳本顯示您正在使用的平台以及如何添加圖例?
非常感謝你的回复。為了方便起見,我將使用此代碼發布並且我剛剛添加了圖形的“本地數據過濾器”部分。
//Begin Script;
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
variables = {"age", "sex"};
// Initial nlevels is the number of levels of 'age', as it is the first by-group used.
fitVar = "age";
nlevels=6;
// Creating the legend. For each selection, the previous spline fits are removed, then
// new ones are generated.
BC_legend = Panel Box( "Choose Legend",
legend = Radio Box(
{"age", "sex"},
fitVar = legend << Get Selected;
Match( fitVar,
"age",
(Summarize(vals = By( :age ), c=count );
For(ii = nlevels, ii >=1, ii--,
obj << (Curve[1] << Remove Fit );
);
report(obj)[BorderBox(2)] << Delete;
report(obj)[FrameBox(1)] << Row Legend("age", color(1), marker(1));
obj << Group By( :age ) << Fit Spline( 0.1, standardized );
nlevels = nItems(vals);
),
"sex",
(Summarize(vals = By( :sex ), c=count );
For(ii = nlevels, ii >=1, ii--,
obj << (Curve[1] << Remove Fit );
);
report(obj)[BorderBox(2)] << Delete;
report(obj)[FrameBox(1)] << Row Legend("sex", color(1), marker(1));
obj << Group By( :sex ) << Fit Spline( 0.1, standardized );
nlevels = nItems(vals); )
);
));
// Fitting the initial Bivariate fit with 'age' as the by-group, adding the legend
// to control the selections.
nw = New Window( "BigClassBivariate",
HListBox(
obj = dt << Bivariate(
Y( :weight ),
X( :height ),
Group By( :age ),
Fit Spline( 0.1, standardized ),
Local Data Filter(
Location( {0, 0} ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) ),
Add Filter(
columns( :age ),
Display( :age, Size( 204, 200 ), List Display )
)
),
SendToReport(
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Frame Size( 493, 354 ),Marker Size( 2 ), Marker Drawing Mode( "Normal" ), Row Legend(
dt:(fitVar),
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "Standard" ),
Continuous Scale( Cont ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
); ,
BC_legend
));
//End Script;
因此,以上面的代碼為例。我在界面的選擇圖例部分中的“年齡”和“性別”之間單擊了兩次,然後使用本地過濾器,然後彈出“舊”圖例。

首先,看起來該問題已通過JMP 15解決。 幸運的是,對於早期版本,有一個簡單的解決方法。
當您使用以下方法刪除舊圖例時:
report(obj)[BorderBox(2)] << Delete;
圖例的顯示部分被刪除,但是DisplayFrame仍然具有舊圖例的句柄,並且當您添加新圖例時,現在有兩個。 您甚至還可以在觸摸數據過濾器之前就看到此內容,如果您保存報告的腳本,則會看到兩個RowLegend()命令。 如果在報表上使用“重做分析”(帶有或不帶有數據過濾器),這兩個圖例也會重新出現。
為了確保完全刪除圖例,而不僅僅是圖例的顯示部分,可以使用以下替換框刪除:
report(obj)[OwnerBox(1)] << Remove;
這等效於在圖例中右鍵單擊>刪除,可以正確刪除它。
希望有幫助!
可行!!!太好了,謝謝你!我的代碼現在很漂亮!!!