使用 JSL 在图形生成器中隐藏图例项我在使用 JSL 中的图形生成器时遇到了一个恼人的问题。为了在散点图上显示点和更平滑,我正在更改点的透明度。我可以使这项工作足够好,但当我稍后在 JSL 中操作绘图时,默认情况下,点将被添加回图例,而不是保持隐藏,我认为是因为 JMP 认为它们不再是多余的。我知道您可以在图形生成器中手动取消选中不想显示的项目,但是有没有办法在 JSL 中执行此操作?


回复:使用 JSL 在图形生成器中隐藏图例项谢谢你@anne_sa 。你的信息为我指明了正确的方向。
回复:使用 JSL 在图形生成器中隐藏图例项谢谢@tx尼尔森和@jjswan33为您解答!
我需要稍微调整它以使其与我的脚本相匹配,但我想我会工作的。
再次感谢 :)
回复:使用 JSL 在图形生成器中隐藏图例项我找到了一个替代解决方案,在我看来,它比吉姆的蛮力方法更干净。
相反,我在函数的开头定义了两个列表:
p = {};
l = {};
summarize(unique_values=by(OverlayCol));
NSplits = N Items (unique_values);
For(i=0, i < NSplits, i+=1,
p = Insert(p, -1);
l = Insert(l, i);
);
pl = Insert(p, l);创建点和线(在我的例子中)图例项所需的两个列表,然后将这些列表作为矩阵传递到图形生成器调度中,如下所示:
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {3, Matrix(p), 9, Matrix(l)} ),
Position( Matrix(pl))}
)完整版更新功能:
RadPlotCreator1XGroupTest = Function({dt, XCol, YCol, OverlayCol, GroupXCol}, {Default Local},
p = {};
l = {};
summarize(unique_values=by(OverlayCol));
NSplits = N Items (unique_values);
For(i=0, i < NSplits, i+=1,
p = Insert(p, -1);
l = Insert(l, i);
);
pl = Insert(p, l);
gb = dt << Graph Builder(
Size( 849, 622 ),
Fit to Window( "Off" ),
Show Control Panel(0),
Grid Color( "Black" ),
Variables(
X( XCol ),
Y( YCol ),
Group X( GroupXCol ),
Overlay( OverlayCol )
),
Elements(Points(X, Y, Legend(3)), Smoother( X, Y, Legend( 9 ) )),
SendToReport(
Dispatch(
{},
"",
ScaleBox,
{}
),
Dispatch(
{},
"",
ScaleBox,
{}
),
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {3, Matrix(p), 9, Matrix(l)} ),
Position( Matrix(pl))}
)
)
);
sb = report(gb)[ScaleBox(5)];
For(i=0, i < NSplits, i+=1,
sb << Legend Model(3, Properties(i, {Transparency(0.2)}));
);
frame_list = gb << xpath("//FrameBox");
num_frames = N Items (frame_list);
For(i=1, i <= num_frames, i+=1,
Report(gb)[Framebox(i)] << Background Color(White);
Report(gb)[Framebox(i)] << Grid Line Order( Back );
Report(gb)[Framebox(i)] << Reference Line Order( Back );
Report(gb)[Framebox(i)] << Frame Size(250, 250);
Report(gb)[Framebox(i)] << X Axis(0, 150, Inc(20), Minor Ticks(1),
Add Ref Line( 70, Solid, "Black", "", 2 ),
Add Ref Line( 120, Solid, "Black", "", 2 ),
Add Ref Line( 135, Solid, "Black", "", 2 ), Show Major Grid( 1 ));
Report(gb)[Framebox(i)] << Y Axis(Minor Ticks(1));
);
gbp = Report( gb );
img = gbp << getpicture();
return(img);
);
回复:使用 JSL 在图形生成器中隐藏图例项这是我用来解决此类问题的强力方法。我只需构建所需的 JSL 代码,然后运行我创建的 JSL。 请注意,在我使用的 Big Class 数据表中,我添加了一个额外的年龄组,即 18 岁。
Names Default To Here( 1 );
dt = Current Data Table();
// Find the number of Age groups
Summarize( dt, ageGroups = by( :age ) );
// Build the JSL
theExpr =
"Graph Builder(
Show Control Panel( 0 ),
Variables( X( :age ), Y( :height ), Color( :age ) ),
Elements( Points( X, Y, Legend( 6 ) ), Box Plot( X, Y, Legend( 7 ) ) ),
SendToReport(
Dispatch(
{},
\!"400\!",
LegendBox,
{Legend Position(
{6, [ -1";
For( i = 2, i <= N Items( ageGroups ), i++,
theExpr = theExpr || ", -1"
);
theExpr = theExpr || "], 7, [0";
For( i = 1, i <= N Items( ageGroups ), i++,
theExpr = theExpr || ", " || Char( i )
);
theExpr = theExpr || ", -3]}
), Position( {-1";
For( i = 2, i <= N Items( ageGroups ), i++,
theExpr = theExpr || ", -1"
);
For( i = 0, i <= N Items( ageGroups ), i++,
theExpr = theExpr || ", " || Char( i )
);
theExpr = theExpr || ", -3]} ) } )));";
// Execute the JSL string
eval(parse(theExpr));

回复:使用 JSL 在图形生成器中隐藏图例项糟糕,复制/粘贴错误,抱歉造成混乱!
让我们重做一次(使用 JMP15)!
首先我有以下图表:

对应的脚本是:
Graph Builder(
Variables( X( :age ), Y( :height ), Color( :age ) ),
Elements( Points( X, Y, Legend( 6 ) ), Box Plot( X, Y, Legend( 7 ) ) )
)
我手动修改图例并取消选择与点关联的项目:

我得到这个图:

更新后的脚本是:
Graph Builder(
Variables( X( :age ), Y( :height ), Color( :age ) ),
Elements( Points( X, Y, Legend( 6 ) ), Box Plot( X, Y, Legend( 7 ) ) ),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position(
{6, [-1, -1, -1, -1, -1, -1], 7, [0, 1, 2, 3, 4, 5, 6, -3]}
), Position( {-1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, -3} )}
)
)
)有没有一种简单的方法可以使用 JSL 来管理第二步?
回复:使用 JSL 在图形生成器中隐藏图例项我个人在 JMP 12 和 JMP 14 中都获得了双重图例。我之前没有发布我的代码,但下面是我用来绘制出现问题的图的函数。就我而言,我相信发生的情况是,一旦我使用代码位设置点的透明度,JMP 就不再认为点图例项是多余的并显示结果。
RadPlotCreator1X1YGroup = Function({dt, XCol, YCol, OverlayCol, GroupXCol, GroupYCol}, {Default Local},
gb = dt << Graph Builder(
Size( 849, 622 ),
Fit to Window( "Off" ),
Show Control Panel(0),
Grid Color( "Black" ),
Variables(
X( XCol ),
Y( YCol ),
Group X( GroupXCol ),
Group Y( GroupYCol ),
Overlay( OverlayCol )
),
Elements(Points(X, Y, Legend(3)), Smoother( X, Y, Legend( 9 ) )),
SendToReport(
Dispatch(
{},
"",
ScaleBox,
{}
),
Dispatch(
{},
"",
ScaleBox,
{}
)
)
);
summarize(unique_values=by(OverlayCol));
NSplits = N Items (unique_values);
sb = report(gb)[ScaleBox(5)];
For(i=0, i < NSplits, i+=1,
sb << Legend Model(3, Properties(i, {Transparency(0.2)}));
);
frame_list = gb << xpath("//FrameBox");
num_frames = N Items (frame_list);
For(i=1, i <= num_frames, i+=1,
Report(gb)[Framebox(i)] << Background Color(White);
Report(gb)[Framebox(i)] << Grid Line Order( Back );
Report(gb)[Framebox(i)] << Reference Line Order( Back );
Report(gb)[Framebox(i)] << Frame Size(250, 250);
Report(gb)[Framebox(i)] << X Axis(0, 150, Inc(20), Minor Ticks(1),
Add Ref Line( 70, Solid, "Black", "", 2 ),
Add Ref Line( 120, Solid, "Black", "", 2 ),
Add Ref Line( 135, Solid, "Black", "", 2 ), Show Major Grid( 1 ));
Report(gb)[Framebox(i)] << Y Axis(Minor Ticks(1));
);
gbp = Report( gb );
img = gbp << getpicture();
return(img);
);回复:使用 JSL 在图形生成器中隐藏图例项您使用的是哪个版本的 JMP,以及在哪个操作系统上。使用您提供的 JSL,我无法获得您指定的结果。对于 JMP 15 我得到

在 JMP 13 和 JMP 14 中我得到:

在 JMP 11 和 JMP 12 中,我得到:

但我无法获得您使用不同标记以及图例中的点和矩形标记呈现的图表。
回复:使用 JSL 在图形生成器中隐藏图例项你好@tx尼尔森,
感谢您的回复。
然而,我不想完全隐藏或删除图例,而只是其中的一部分。
默认情况下,我有以下图表:

我想只隐藏图例中的点项目以获得该项目:

显然,图例位置选项中的“-1”意味着“隐藏此项目”,但我不知道如何在没有有关图表的事先信息的情况下轻松使用此选项。
我希望它更清楚。
回复:使用 JSL 在图形生成器中隐藏图例项您可以使用“显示图例”元素来控制图例的显示或隐藏。这是脚本索引中显示它的条目
帮助==>脚本索引

您还可以使用 JMP 中的显示树功能删除整个图例组件
gb = Graph Builder(
Size( 528, 450 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( :height ), Color( :age ) ),
Elements( Box Plot( X, Y))
);
report(gb)[LegendBox(1)]<<DELETE></DELETE>
回复:使用 JSL 在图形生成器中隐藏图例项大家好,
我目前面临同样的问题:使用 JSL 隐藏图形生成器图例的一部分。
我认为“图例”或“图例位置”选项可能会有所帮助,但我很难完全理解它是如何工作的,特别是如果我们不知道组的数量。
例如,我想使用 Big Class 表创建这种图表,并且我不想在图例中显示点项:

对应的脚本是:
Graph Builder(
Size( 528, 450 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( :height ), Color( :age ) ),
Elements( Box Plot( X, Y, Legend( 4 ) ), Points( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position(
{4, [0, 1, 2, 3, 4, 5, 6, -3], 5, [-1, -1, -1, -1, -1, -1]}
), Position( {0, 1, 2, 3, 4, 5, 6, -3, -1, -1, -1, -1, -1, -1} )}
)
)
)有没有办法在不知道年龄变量的级别数的情况下概括该过程?
任何意见将不胜感激:)谢谢
回复:使用 JSL 在图形生成器中隐藏图例项我想 JSL 没有解决这个问题的方法。如果真是这样的话,那就应该如此了。