I have a script that generates boxplots in Graph Builder, but as it was first captured from a graph. Here is the code:
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)}
)
}
)
)
)
);Near the bottom is the FrameBox block where you can see a DispatchSeg for each boxplot that was created from the original graph. What I wish to do is make that section of the code dynamic, as the number of sites may be different for each site population.
What I need is a way to capture the number of unique sites that have not been excluded, and then use that count to create a loop to set the line and fill colors for each boxplot. How can I go about this.
The example might have "too much nformation" it was created as a learning script for customizing GraphBuilder for JMP 13 but works for later versions. It aso creates custom labels. JMP 15 has ne features of Textlet, Graphlet, etc that might make it easier to add the custom text. The script is attached and the picture it creates is shown below.
There are several key features to do what you want:
If you are new to JSL, you will likely need to look up some features in the Help > Scripting Index for XPath, GraphBuilderBox and FrameBox.
I recommend running the script as described below:
The key code is:
//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});
I hope this is enough to get you started. Oh, you need to remove the Dispatch statements targeting individual boxplots in your saved script. the attached script kept three dispatch statements just for comparing symatx and training purposes.
Thanks for the response. I will look into what you have cited, but some of your response seems to be unrelated to my particular issue, but it is good information nonetheless.