我有一个在图形生成器中生成箱线图的脚本,但它是首先从图形中捕获的。 这是代码:
inboundDataTable << New Script("Boxplots and Means for Sites w/Low Read Rates",
Names Default to Here(1);
Delete Symbols();
inboundData = Current Data Table();
inboundData << Graph Builder(
Size(650, 481),
Grid Color({79, 98, 40}),
Variables(X(:IDENT Code), Y(:Read Rate)),
Elements(
Box Plot(X, Y, Legend(2), Jitter("Random Normal")),
Points(X, Y, Legend(3), Summary Statistic("Mean"))
),
SendToReport(
Dispatch(
{},
"Read Rate",
ScaleBox,
{
Format("Percent", 5, 0),
Minor Ticks(4),
Add Ref Line(0.95, "Solid", {255, 0, 0}, "", 1),
Label Row({Show Major Grid(1), Show Minor Grid(1)})
}
),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
2,
Base(1, 0, 0, Item ID("Read Rate", 2)),
Properties(1, {Fill Color(0)}, Item ID("Read Rate", 2)),
Properties(
-1,
{Line Color(-4221340), Marker("FilledCircle"), Fill Color(0)},
Item ID("Mean", 1)
)
), Legend Model(
3,
Properties(
0,
{Line Color(-16776960), Marker("Diamond"), Fill Color(0)},
Item ID("Mean", 1)
)
)}
),
Dispatch({}, "X title", TextEditBox, {Set Text("Crossing (Site)")}),
Dispatch(
{},
"Graph Builder",
FrameBox,
{
Marker Size(5), Grid Line Order(1), Reference Line Order(2),
DispatchSeg(
Box Plot Seg("Box Plot (ALC)"),
{Line Color({44, 77, 117}), Fill Color({79, 129, 189}), Fill(1)}
),
DispatchSeg(
Box Plot Seg("Box Plot (CIA)"),
{Line Color({44, 77, 117}), Fill Color({79, 129, 189}), Fill(1)}
),
DispatchSeg(
Box Plot Seg("Box Plot (JKM)"),
{Line Color({44, 77, 117}), Fill Color({79, 129, 189}), Fill(1)}
),
DispatchSeg(
Box Plot Seg("Box Plot (POR)"),
{Line Color({44, 77, 117}), Fill Color({79, 129, 189}), Fill(1)}
),
DispatchSeg(
Box Plot Seg("Box Plot (RAI)"),
{Line Color({44, 77, 117}), Fill Color({79, 129, 189}), Fill(1)}
),
DispatchSeg(
Box Plot Seg("Box Plot (THO)"),
{Line Color({44, 77, 117}), Fill Color({79, 129, 189}), Fill(1)}
)
}
)
)
)
);靠近底部的是 FrameBox 块,您可以在其中看到从原始图形创建的每个箱线图的 DispatchSeg。 我希望做的是使代码的该部分动态化,因为每个站点群体的站点数量可能不同。
我需要的是一种方法来捕获尚未排除的唯一站点的数量,然后使用该计数创建一个循环来设置每个箱线图的线条和填充颜色。 我该怎么办呢。
@mdawson69 ,
该示例可能包含“太多信息”,它是作为用于自定义 JMP 13 的 GraphBuilder 的学习脚本而创建的,但适用于更高版本。它还创建自定义标签。JMP 15 具有 Textlet、Graphlet 等新功能,可以更轻松地添加自定义文本。 脚本已附上,其创建的图片如下所示。
有几个关键功能可以满足您的需求:
- 如何获取由 X 变量定义的箱线图数量。 该脚本使用 XPath 创建箱线图参考 bpseg[i]
- 如何使用 JSL 发送语法 << 代替 Dispatch
- 对于循环。
如果您是 JSL 新手,您可能需要在帮助 > 脚本索引为了X路径,图形生成器框和框架框。
我建议按如下所述运行脚本:
- 高亮显示并运行第 1 至 50 行。
- 阅读、突出显示并运行第 51 至 54 行,查看对所有箱线图所做的更改
- 阅读、突出显示并运行第 55 至 59 行,了解如何一次更改一个箱线图
关键代码是:
//assume you like March's style and do not want to show the points
//here is the code to set all
bpseg = gb << Xpath("//BoxPlotSeg");
bpseg << {Box Style( "Solid" ), Confidence Diamond( 1 ), Fences( 0 )};
//if you want to color each by month
for(i=1, i<=nitems(bpseg), i++,
bpseg[i] << Fill Color(Color Of(As Row State(cc[i])))
);
//if you want to remove points. since ponts are the 3rd element
report(gb)[GraphBuilderBox(1)] << remove element(1,1,3);
//to add them back, uncomment and run the next line
//report(gb)[GraphBuilderBox(1)] << Add Element(1, 1, {Type("Points"), X, Y});
我希望这足以让您开始。哦,您需要删除保存的脚本中针对单个箱线图的 Dispatch 语句。附加的脚本保留了三个调度语句,仅用于比较 symatx 和训练目的。
