当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?以下示例脚本来自较早的线程(已解决,感谢@jthi )我的允许我将 Y 变量绘制为列表中的点。
我想添加箱线图此外积分在我的图表中。 如何在下面的脚本中添加箱线图?
Names Default To Here(1);
dt = Open("$sample_data\Big Class.jmp");
y_values = {"name", "age", "sex", "weight"};
variables_expr = Expr(Variables(X(:height)));
For Each({y_col}, y_values,
temp_expr = Expr(Y());
Insert Into(temp_expr, Name Expr(AsColumn(dt, y_col)));
Insert Into(variables_expr, Name Expr(temp_expr));
);
gb_expr = Expr(Graph Builder(
Show Control Panel(0)
));
Insert Into(gb_expr, Name Expr(variables_expr));
For Each({y_col, idx}, y_values,
Eval(EvalExpr(
Insert Into(gb_expr,
Name Expr(Elements(Position(1, Expr(idx)), Points(X, Y, Legend(Expr(idx)))))
)
));
);
Show(Name Expr(gb_expr));
Eval(gb_expr);自动化和脚本编写视窗回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?在 JMP 中交互式创建图形

将脚本保存到剪贴板/脚本窗口
Graph Builder(
Show Control Panel(0),
Variables(X(:height), Y(:name), Y(:age), Y(:sex), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(1)), Box Plot(X, Y, Legend(5))),
Elements(Position(1, 2), Points(X, Y, Legend(2)), Box Plot(X, Y, Legend(6))),
Elements(Position(1, 3), Points(X, Y, Legend(3)), Box Plot(X, Y, Legend(7))),
Elements(Position(1, 4), Points(X, Y, Legend(4)), Box Plot(X, Y, Legend(8))),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position(
{1, [0], 5, [4, -3], 2, [1], 6, [5, -3], 3, [2], 7, [6, -3], 4, [3],
8, [7, -3]}
)}
)
)
)
当原始图形生成器如下所示时,请查看必须更改哪些内容才能包含 BoxPlots
Graph Builder(
Show Control Panel(0),
Variables(X(:height), Y(:name), Y(:age), Y(:sex), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(1))),
Elements(Position(1, 2), Points(X, Y, Legend(2))),
Elements(Position(1, 3), Points(X, Y, Legend(3))),
Elements(Position(1, 4), Points(X, Y, Legend(4)))
)
返回到您的脚本并尝试进行一些小的修改。 您可以很容易地看到,您缺少 Elements 中的某些内容并且基于您的原始脚本
Name Expr(Elements(Position(1, Expr(idx)), Points(X, Y, Legend(Expr(idx)))))
看来你应该尝试在那里添加正确格式的箱线图
回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?运行图表。
打开控制面板
添加您想要的箱线图。
关闭控制面板
转到红色三角形并选择
保存=>脚本到脚本窗口
检查代码,并更改脚本以添加新脚本具有而旧脚本没有的附加项目。
回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?@tx尼尔森我一直在这样做,以交互方式添加箱形图,然后检查生成的脚本,在我的原始脚本中进行更改,仍然无法使箱形图工作。我想我仍然不擅长发现缺少/需要的东西。
会尝试@jthi现在建议。
回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?运行您的 JSL,然后将图表修改为您想要的外观,然后保存新图表中的 JSL。将新的 JSL 添加到此讨论轨道,我将查看它。
回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?@tx尼尔森以下内容接近我的实际情况。
Names default To Here (1);
Clear Log ();
dt = Open("$sample_data\Semiconductor Capability.jmp");
y_values = {"NPN1", "IVP1", "PNP4", "NPN4"};
variables_expr = Expr(Variables(X(:lot_id)));
For Each({y_col}, y_values,
temp_expr = Expr(Y());
Insert Into(temp_expr, Name Expr(AsColumn(dt, y_col)));
Insert Into(variables_expr, Name Expr(temp_expr));
);
gb_expr = Expr(Graph Builder(
Show Control Panel(0)
));
Insert Into(gb_expr, Name Expr(variables_expr));
For Each({y_col, idx}, y_values,
Eval(EvalExpr(
Insert Into(gb_expr,
Name Expr(Elements(Position(1, Expr(idx)), Points(X, Y, Legend(Expr(idx)))))
)
));
);
Show(Name Expr(gb_expr));
Eval(gb_expr); 这使

但是,我想要以下内容

JMP 生成的脚本是
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :lot_id ), Y( :NPN1 ), Y( :IVP1 ), Y( :PNP4 ), Y( :NPN4 ) ),
Elements(
Position( 1, 1 ),
Points( X, Y, Legend( 1 ), Jitter( "None" ) ),
Box Plot( X, Y, Legend( 5 ), Jitter( "None" ) )
),
Elements(
Position( 1, 2 ),
Points( X, Y, Legend( 2 ), Jitter( "None" ) ),
Box Plot( X, Y, Legend( 6 ), Jitter( "None" ) )
),
Elements(
Position( 1, 3 ),
Points( X, Y, Legend( 3 ), Jitter( "None" ) ),
Box Plot( X, Y, Legend( 7 ), Jitter( "None" ) )
),
Elements(
Position( 1, 4 ),
Points( X, Y, Legend( 4 ), Jitter( "None" ) ),
Box Plot( X, Y, Legend( 8 ), Jitter( "None" ) )
),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position(
{1, [0], 5, [4, -3], 2, [1], 6, [5, -3], 3, [2], 7, [6, -3], 4, [3],
8, [7, -3]}
)}
)
)
);问题是如何修改这篇文章中的顶部脚本以除了点之外还包括箱形图?
在 Points () 下面添加 Box Plots () 并没有给我两者。
我想我对箱线图 () 的放置不正确。 这里需要帮助。
回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?我认为您使用了默认的“箱线图”离群值。
您是否正在寻找连接所有点的“箱线图”分位数方法?

Graph Builder(
Size( 1135, 705 ),
Show Control Panel( 0 ),
Variables(
X( :“S-b"n ),
Y( :C),
Color( :“S-b"n )
),
Elements( Box Plot( X, Y, Legend( 4 ), Box Type( "Quantile" ) ) )
);
回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?需要非常小的更改才能生成您想要的图表。
运行图形生成器的初始脚本生成的 JSL 是
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :lot_id ), Y( :NPN1 ), Y( :IVP1 ), Y( :PNP4 ), Y( :NPN4 ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 1 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 2 ) ) ),
Elements( Position( 1, 3 ), Points( X, Y, Legend( 3 ) ) ),
Elements( Position( 1, 4 ), Points( X, Y, Legend( 4 ) ) )
);
当人们查看创建上述图形生成器代码的 JSL 时,会发现只有 2 个部分完成了真正的工作。
gb_expr = Expr(Graph Builder(
Show Control Panel(0)
));
为图形生成器创建外壳
Graph Builder(
Show Control Panel( 0 ),
);
JSL
variables_expr = Expr(Variables(X(:lot_id)));
For Each({y_col}, y_values,
temp_expr = Expr(Y());
Insert Into(temp_expr, Name Expr(AsColumn(dt, y_col)));
Insert Into(variables_expr, Name Expr(temp_expr));
);
生成代码
Variables( X( :lot_id ), Y( :NPN1 ), Y( :IVP1 ), Y( :PNP4 ), Y( :NPN4 ) )
然后,
Insert Into(gb_expr, Name Expr(variables_expr));
将变量 ( X(.................) JSL 插入到 Graph Builder() 代码中
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :lot_id ), Y( :NPN1 ), Y( :IVP1 ), Y( :PNP4 ), Y( :NPN4 ) )
);
现在需要做的是构建
Elements( Position( 1, 1 ), Points( X, Y, Legend( 1 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 2 ) ) ),
Elements( Position( 1, 3 ), Points( X, Y, Legend( 3 ) ) ),
Elements( Position( 1, 4 ), Points( X, Y, Legend( 4 ) ) )
创建这些代码行的 JSL 是
For Each({y_col, idx}, y_values,
Eval(EvalExpr(
Insert Into(gb_expr,
Name Expr(Elements(Position(1, Expr(idx)), Points(X, Y, Legend(Expr(idx)))))
)
));
);
它循环遍历每个 Y 值并一次创建一行元素,并将其插入到 Graph Builder() JSL 中。
最后,
Eval(gb_expr);
运行已完成的 Graph Builder JSL
那么现在,需要改变什么。
基本上,如果查看原始脚本创建的 JSL 与经过新修改的图形生成器保存的 JSL 之间的差异,在原始脚本输出中,Elements 结构为
Elements( Position( 1, 1 ), Points( X, Y, Legend( 1 ) ) )
其中“已保存代码”的“元素”部分包含“点”和“箱线图”部分
Elements(
Position( 1, 1 ),
Points( X, Y, Legend( 1 ), Jitter( "None" ) ),
Box Plot( X, Y, Legend( 5 ), Jitter( "None" ) )
)
因此,需要更改的只是将第二部分添加到生成 Elements 部分的代码中。
For Each( {y_col, idx}, y_values,
Eval(
Eval Expr(
Insert Into(
gb_expr,
Name Expr(
Elements(
Position( 1, Expr( idx ) ),
Points( X, Y, Legend( Expr( idx ) ), jitter( "None" ) ),
Box Plot( X, Y, Legend( Expr( N Items( y_values ) + idx ), jitter( "None" ) ) )
)
)
)
)
)
);
如果将所有这些放在一起,新脚本就是
Names Default To Here( 1 );
Clear Log();
dt = Open( "$sample_data\Semiconductor Capability.jmp" );
y_values = {"NPN1", "IVP1", "PNP4", "NPN4"};
variables_expr = Expr(
Variables( X( :lot_id ) )
);
For Each( {y_col}, y_values,
temp_expr = Expr( Y() );
Insert Into( temp_expr, Name Expr( As Column( dt, y_col ) ) );
Insert Into( variables_expr, Name Expr( temp_expr ) );
);
gb_expr = Expr(
Graph Builder( Show Control Panel( 0 ) )
);
Insert Into( gb_expr, Name Expr( variables_expr ) );
For Each( {y_col, idx}, y_values,
Eval(
Eval Expr(
Insert Into(
gb_expr,
Name Expr(
Elements(
Position( 1, Expr( idx ) ),
Points( X, Y, Legend( Expr( idx ) ), jitter( "None" ) ),
Box Plot( X, Y, Legend( Expr( N Items( y_values ) + idx ), jitter( "None" ) ) )
)
)
)
)
)
);
Show( Name Expr( gb_expr ) );
Eval( gb_expr );回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?@tx尼尔森谢谢。
我不会轻易想到这个。
Box Plot( X, Y, Legend( Expr( N Items( y_values ) + idx ), jitter( "None" ) ) )
如何将 Points 中的默认标记更改为“+”或“方块”。 这并不能解决问题
Points( X, Y, Legend( Expr( idx ) ), jitter( "None" ), marker ("square") )改变标记交互式地表明我需要通过 sendToReport () 为每个 Y 变量指示标记更改。 如何同时对所有 Y 变量执行此操作?
回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?取决于你在哪里做,在哪里看到什么会有所不同。 如果您从 Legend 执行此操作,请参见以下示例:
从传说中改变它,你会得到类似的东西
{Legend Model(4, Properties(0, {Marker("Circle")}, Item ID("NPN4", 1)))}
因此从脚本索引中搜索图例模型

从那里获取脚本,修改它以满足您的需求,但保持尽可能简单(添加第二个 Y 轴)并测试它
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 448),
Show Control Panel(0),
Variables(X(:sex), Y(:height), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(3))),
Elements(Position(1, 2), Points(X, Y, Legend(1)))
);
server = gb << Get Legend Server;
item = server << Get Legend Item(1, 1);
item << Set Properties({Marker("Circle")});
您成功地更改了一张图上的标记。 然后你会问:我如何在所有地块上更改它们? 然后更详细地探索脚本,似乎提供了一些索引
item = server << Get Legend Item(1, 1);
检查 << 从脚本索引中获取图例项目并希望它在那里,如果它不存在,则探索其他图例相关对象并希望它们以类似的方式工作(或者只是尝试将消息发送到服务器 << get legend Ctrl+Space这里)。
server << Get Legend Items;
{{LegendModelItem(Label("height"), Type("Marker"))},
{LegendModelItem(Label("weight"), Type("Marker"))}}
现在您有一个图例项目列表。 尝试循环该列表,看看会发生什么
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 448),
Show Control Panel(0),
Variables(X(:sex), Y(:height), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(3))),
Elements(Position(1, 2), Points(X, Y, Legend(1)))
);
server = gb << Get Legend Server;
For Each({item}, server << Get Legend Items,
item << Set Properties({Marker("Circle")});
);
更简单的选择是将标记设置为数据表的行状态(如果这适合您)。
回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?@jthi谢谢。 有没有办法在首先绘制点时更改标记,而不是稍后获取图例服务器的句柄,然后更改每个 Y 变量的标记?
回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?难道有什么原因导致之后无法更改吗?
您可以使用 SendToReport 并在 Dispatch 部分中构建 Legend 模型,其想法与脚本中其他部分的构建类似。
回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?@jthi当然事情之后可能会改变。 在绘制点时更改标记对我来说似乎是一条更简单的路线。
回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?@jthi @tx尼尔森在下面的主脚本中,我在 Eval() 下添加了本地数据过滤器 () ,它按预期工作
Eval( gb_expr <<LOCAL data="https://community.jmp.com/" filter=""></LOCAL>
但如果我添加用于更新标记的脚本,图表就会绘制两次!
Eval(
server = gb_expr << Get Legend Server;
For Each( {item}, server << Get Legend Items, item << Set Properties( {Marker( "Circle" )} ) );
);<BR />
Names Default To Here( 1 );
Clear Log();
dt = Open( "$sample_data\Semiconductor Capability.jmp" );
y_values = {"NPN1", "IVP1", "PNP4", "NPN4"};
variables_expr = Expr(
Variables( X( :lot_id ) )
);
For Each( {y_col}, y_values,
temp_expr = Expr( Y() );
Insert Into( temp_expr, Name Expr( As Column( dt, y_col ) ) );
Insert Into( variables_expr, Name Expr( temp_expr ) );
);
gb_expr = Expr(
Graph Builder( Show Control Panel( 0 ) )
);
Insert Into( gb_expr, Name Expr( variables_expr ) );
For Each( {y_col, idx}, y_values,
Eval(
Eval Expr(
Insert Into(
gb_expr,
Name Expr(
Elements(
Position( 1, Expr( idx ) ),
Points( X, Y, Legend( Expr( idx ) ), jitter( "None" ) ),
Box Plot( X, Y, Legend( Expr( N Items( y_values ) + idx ), jitter( "None" ) ) )
)
)
)
)
)
);
//Show( Name Expr( gb_expr ) );
Eval( gb_expr <<LOCAL data="https://community.jmp.com/" filter=""></LOCAL>第二个图表包含更新的标记。
如何使用更新的标记和本地数据过滤器绘制单个图表?
我想,我无法在我请求帮助的地方正确放置最后一块用于标记更改的位置。
回复:当将 Y 变量作为列表提供给图形生成器时,如何将箱线图添加到点?您不想运行 gb_expr 两次。 您想要获取从 gb_expr 获得的引用并将这些消息发送给它
gb = Eval( gb_expr );
gb << Local data Filter(...)
server = gb << get legend server;