您好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;
这等效于在图例中右键单击>删除,可以正确删除它。
希望有帮助!
可行!!!太好了,谢谢你!我的代码现在很漂亮!!!