How do I define spec limits by data category in variability chartHi,
How can I draw spec limits(red line) by data category in variability chart as below example? The red line was done by manual in pptx.
Attach jmp file data for reference. Appreciate for your reply. Thanks.

Automation and ScriptingBasic Data Analysis and ModelingWindowsRe: How do I define spec limits by data category in variability chartDoes Varying spec limits by data category in variability chart give some ideas?
Re: How do I define spec limits by data category in variability chartHi jthi,
I checked and followed steps, but it still didn't work, even directly used its attachment file and script.
Re: How do I define spec limits by data category in variability chartUsing your data (+ adding limits) and making small fix to the script from that thread

Re: How do I define spec limits by data category in variability chartHi jthi,
You did indeed draw the chart I wanted, but I still don't know how to modify the script. Anyway, thanks for your reply
Re: How do I define spec limits by data category in variability chartNames Default To Here(1);
dt1 = Open("$DOWNLOADS/sample data.jmp");
dt = dt1 << Stack( // stack to get proper data format
columns(:A10, :A20, :A30),
Source Label Column("SampleGroup"),
Output Table("Stack")
);
// Add limits as they were not provided
dt << New Column("LSL", Numeric, Continuous, Values([10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20]));
dt << New Column("Target", Numeric, Continuous, Values([20, 20, 20, 20, 20, 20, 20, 20, 20, 40, 40, 40, 40, 40, 40, 40, 40, 40]));
dt << New Column("USL", Numeric, Continuous, Values([30, 30, 30, 30, 30, 30, 30, 30, 30, 50, 50, 50, 50, 50, 50, 50, 50, 50]));
var = dt << Variability Chart(Y(:Data), X(:Phase, :SampleGroup));
dt_summary = dt << Summary(
Group(:Phase),
Max(:LSL),
Mean(:Target),
Min(:USL),
N Categories(:SampleGroup),
Freq("None"),
Weight("None"),
statistics column name format("column"),
Link to original data table(0)
);
dt_summary << Delete Columns("N Rows");
// We need access to the framebox
fb = Report(var)[Outline Box("Variability Chart for Data"), Frame Box(1)];
//Get phases count (this was missing)
Summarize(dt, phases = By(:Phase));
// Using graphic scripts most likely easiest option
xidx = 0;
For(i = 1, i <= N Items(phases), i++,
curphase = dt_summary[i, "Phase"];
curlsl = dt_summary[i, "LSL"];
curusl = dt_summary[i, "USL"];
curtarget = dt_summary[i, "Target"];
curcount = dt_summary[i, "SampleGroup"];
xend = xidx + curcount;
lslstart = Eval List({xidx, curlsl});
lslend = Eval List({xend, curlsl});
uslstart = Eval List({xidx, curusl});
uslend = Eval List({xend, curusl});
targetstart = Eval List({xidx, curtarget});
targetend = Eval List({xend, curtarget});
xidx = xend;
Eval(EvalExpr(
fb << Add Graphics Script(
Pen Color("Red");
Pen Size(1);
Line(Expr(lslstart), Expr(lslend)); // {x1, y1}, {x2, y2}
Line(Expr(uslstart), Expr(uslend)); // {x1, y1}, {x2, y2}
Pen Color("Blue");
Line(Expr(targetstart), Expr(targetend)); // {x1, y1}, {x2, y2}
);
));
);
fb << Y Axis(Max(1.1*Max(Col Max(Column(dt, "Data")), Col Max(Column(dt_summary, "USL"))))); // adjust yaxisRe: How do I define spec limits by data category in variability chartHi jthi,
Thanks for your script, it's worked successfully.
Regarding the limit setting below, if I have up to 100 data and only add limit line on dedicated "Phase", are there any solutions to optimize the following script? Thanks
// Add limits as they were not provided
dt << New Column("LSL", Numeric, Continuous, Values([10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20]));
dt << New Column("Target", Numeric, Continuous, Values([20, 20, 20, 20, 20, 20, 20, 20, 20, 40, 40, 40, 40, 40, 40, 40, 40, 40]));
dt << New Column("USL", Numeric, Continuous, Values([30, 30, 30, 30, 30, 30, 30, 30, 30, 50, 50, 50, 50, 50, 50, 50, 50, 50]));Re: How do I define spec limits by data category in variability chartYou could create spec limit table or if you don't have too many parameters, associative array for that
Names Default To Here(1);
dt1 = Open("$DOWNLOADS/sample data.jmp");
dt = dt1 << Stack( // stack to get proper data format
columns(:A10, :A20, :A30),
Source Label Column("SampleGroup"),
Output Table("Stack")
);
aa_specs = [
"L1" => ["LSL" => 10, "USL" => 30, "Target" => 20],
"L2" => ["LSL" => 30, "USL" => 50, "Target" => 40]
];
// Add limits as they were not provided
dt << New Column("LSL", Numeric, Continuous);
dt << New Column("Target", Numeric, Continuous);
dt << New Column("USL", Numeric, Continuous);
For Each Row(dt,
:LSL = aa_specs[:Phase]["LSL"];
:USL = aa_specs[:Phase]["USL"];
:Target = aa_specs[:Phase]["Target"];
);
Or using spec table
Names Default To Here(1);
dt1 = Open("$DOWNLOADS/sample data.jmp");
dt = dt1 << Stack( // stack to get proper data format
columns(:A10, :A20, :A30),
Source Label Column("SampleGroup"),
Output Table("Stack")
);
dt_specs = New Table("Specs",
Add Rows(2),
Compress File When Saved(1),
New Column("Variable", Character, "Nominal", Set Values({"L1", "L2"})),
New Column("LSL", Numeric, "Continuous", Format("Best", 12), Set Values([10, 30])),
New Column("Target", Numeric, "Continuous", Format("Best", 12), Set Values([20, 40])),
New Column("USL", Numeric, "Continuous", Format("Best", 12), Set Values([30, 50]))
);
dt << Update(
With(dt_specs),
Match Columns(:Phase = :Variable)
);
Close(dt_specs, no save);Re: How do I define spec limits by data category in variability chartHi jthi,
It worked when I used method1.
Assuming I want L2 to not have USL/LSL, how can I optimize it?
I tried setting value= 0, but a red line will show at the Y-zero position.
I put //"L2" => ["LSL" => 0, "USL" => 0, //"Target" => 40], it's not work.
aa_specs = [
"L1" => ["LSL" => 10, "USL" => 30, "Target" => 20],
"L2" => ["LSL" => 0, "USL" => 0, //"Target" => 40]
];
Re: How do I define spec limits by data category in variability chartI would set the value as missing if you don't wish to have it and I think it should work with the script.
View more...
Names Default To Here(1);
dt1 = Open("$DOWNLOADS/sample data.jmp");
dt = dt1 << Stack( // stack to get proper data format
columns(:A10, :A20, :A30),
Source Label Column("SampleGroup"),
Output Table("Stack")
);
aa_specs = [
"L1" => ["LSL" => 10, "USL" => 30, "Target" => 20],
"L2" => ["LSL" => 30, "USL" => ., "Target" => .]
];
// Add limits as they were not provided
dt << New Column("LSL", Numeric, Continuous);
dt << New Column("Target", Numeric, Continuous);
dt << New Column("USL", Numeric, Continuous);
For Each Row(dt,
:LSL = aa_specs[:Phase]["LSL"];
:USL = aa_specs[:Phase]["USL"];
:Target = aa_specs[:Phase]["Target"];
);
var = dt << Variability Chart(Y(:Data), X(:Phase, :SampleGroup));
dt_summary = dt << Summary(
Group(:Phase),
Max(:LSL),
Mean(:Target),
Min(:USL),
N Categories(:SampleGroup),
Freq("None"),
Weight("None"),
statistics column name format("column"),
Link to original data table(0)
);
dt_summary << Delete Columns("N Rows");
// We need access to the framebox
fb = Report(var)[Outline Box("Variability Chart for Data"), Frame Box(1)];
//Get phases count (this was missing)
Summarize(dt, phases = By(:Phase));
// Using graphic scripts most likely easiest option
xidx = 0;
For(i = 1, i <= N Items(phases), i++,
curphase = dt_summary[i, "Phase"];
curlsl = dt_summary[i, "LSL"];
curusl = dt_summary[i, "USL"];
curtarget = dt_summary[i, "Target"];
curcount = dt_summary[i, "SampleGroup"];
xend = xidx + curcount;
lslstart = Eval List({xidx, curlsl});
lslend = Eval List({xend, curlsl});
uslstart = Eval List({xidx, curusl});
uslend = Eval List({xend, curusl});
targetstart = Eval List({xidx, curtarget});
targetend = Eval List({xend, curtarget});
xidx = xend;
Eval(EvalExpr(
fb << Add Graphics Script(
Pen Color("Red");
Pen Size(1);
Line(Expr(lslstart), Expr(lslend)); // {x1, y1}, {x2, y2}
Line(Expr(uslstart), Expr(uslend)); // {x1, y1}, {x2, y2}
Pen Color("Blue");
Line(Expr(targetstart), Expr(targetend)); // {x1, y1}, {x2, y2}
);
));
);
fb << Y Axis(Max(1.1*Max(Col Max(Column(dt, "Data")), Col Max(Column(dt_summary, "USL"))))); // adjust yaxis
You could also modify the script slightly and make sure it ignores those which have missing values, but it might not be necessary
Re: How do I define spec limits by data category in variability chartHi Jarmo,
I try to change to Graph Box from line, but it's not work with the modified script below. how could I modify?
Eval(EvalExpr(
fb << Add Graphics Script(
Fill Color("Green");
Transparency( 0.3 );
Graph Box(Expr(lslstart), Expr(lslend)); // {x1, y1}, {x2, y2}
Graph Box(Expr(uslstart), Expr(uslend)); // {x1, y1}, {x2, y2}Re: How do I define spec limits by data category in variability chartIs there a specific reason to try and modify Graph Box within the Graphic Script?
Re: How do I define spec limits by data category in variability chartHi Jarmo,
When there are multiple sets of X-Axis phase/groups, this line may obscure the boxplot data points. I would like to use the following image instead.

Re: How do I define spec limits by data category in variability chartThen you could use Rect instead of Line(), no need for graph box (graph box basically is already there). You will have to manage missing values someway if you go with this option as missing points will cause issues with Rect()

Eval(EvalExpr(
fb << Add Graphics Script(
Transparency(0.2);
Pen Color("Green");
Fill Color("Green");
Rect(Expr(lslstart), Expr(uslend), 1);
);
));Re: How do I define spec limits by data category in variability chartHi Jarmo,
Thanks for your prompt reply.
One more question for adding additional X-Axis value.
When I input other X value(SampleA), I modified script below. But the result of limit line is incorrect, how can I modify it?
var = dt << Variability Chart(Y(:Data), X(:Phase, :SampleGroup, :SampleA));
dt_summary = dt << Summary(
Group(:Phase),
Max(:LSL),
Mean(:Target),
Min(:USL),
N Categories(:SampleGroup, :SampleA),
Freq("None"),
Weight("None"),
statistics column name format("column"),
Link to original data table(0)
);
dt_summary << Delete Columns("N Rows");
// We need access to the framebox
fb = Report(var)[Outline Box("Variability Chart for Data"), Frame Box(1)];
//Get phases count (this was missing)
Summarize(dt, phases = By(:Phase));
// Using graphic scripts most likely easiest option
xidx = 0;
For(i = 1, i <= N Items(phases), i++,
curphase = dt_summary[i, "Phase"];
curlsl = dt_summary[i, "LSL"];
curusl = dt_summary[i, "USL"];
curtarget = dt_summary[i, "Target"];
curcount = dt_summary[i, "SampleGroup", "SampleA"];
xend = xidx + curcount;
lslstart = Eval List({xidx, curlsl});
lslend = Eval List({xend, curlsl});
uslstart = Eval List({xidx, curusl});
uslend = Eval List({xend, curusl});
targetstart = Eval List({xidx, curtarget});
targetend = Eval List({xend, curtarget});
xidx = xend;
Eval(EvalExpr(
fb << Add Graphics Script(
Pen Color("Red");
Pen Size(1);
Line(Expr(lslstart), Expr(lslend)); // {x1, y1}, {x2, y2}
Line(Expr(uslstart), Expr(uslend)); // {x1, y1}, {x2, y2}
Pen Color("Blue");
Line(Expr(targetstart), Expr(targetend)); // {x1, y1}, {x2, y2}
);
));
);
fb << Y Axis(Max(1.1*Max(Col Max(Column(dt, "Data")), Col Max(Column(dt_summary, "USL"))))); // adjust yaxisRe: How do I define spec limits by data category in variability chartHow are the limits formed (based on which groups)? What is going wrong? Most likely you have to adjust Summary, possible Summarize and curcount value.
Re: How do I define spec limits by data category in variability chartYes, I noticed that, so I modified script for Summarize and curcount value. But limit line cannot completely cover all the conditions under phase. Limits are still based on "phase". (Please ignore that there is no new SampleA X-Axis)

Re: How do I define spec limits by data category in variability chartYou could create new column into your main table which is combination of SampleGroup, :SampleA for example by concatenating them. Then use that for the N Categories in Summary and for curcount to get the correct counts.
Re: How do I define spec limits by data category in variability chartvar = dt << Variability Chart(Y(:Data), X(:Phase, :SampleGroup, :SampleA));
dt_summary = dt << Summary(
Group(:Phase),
Max(:LSL),
Mean(:Target),
Min(:USL),
N Categories(:SampleGroup, :SampleA),
Freq("None"),
Weight("None"),
statistics column name format("column"),
Link to original data table(0)
);
dt_summary << Delete Columns("N Rows");
// We need access to the framebox
fb = Report(var)[Outline Box("Variability Chart for Data"), Frame Box(1)];
//Get phases count (this was missing)
Summarize(dt, phases = By(:Phase));
// Using graphic scripts most likely easiest option
xidx = 0;
For(i = 1, i <= N Items(phases), i++,
curphase = dt_summary[i, "Phase"];
curlsl = dt_summary[i, "LSL"];
curusl = dt_summary[i, "USL"];
curtarget = dt_summary[i, "Target"];
curcount = dt_summary[i, "N Rows"];
I modified script above, but limit line can't generate. How could I modify it?
Re: How do I define spec limits by data category in variability chartWhat goes wrong with it (I don't have your data so I cannot check)?
Re: How do I define spec limits by data category in variability chartRefer to attachments for test data and script.
Re: How do I define spec limits by data category in variability chartLike I said earlier, easiest option is to create new grouping column and use that in your Summary table. It might also be enough to just get sum of the n categories over multiple groups
curcount = Sum(dt_summary[i, {"Leg", "Layer"}]);Re: How do I define spec limits by data category in variability chartHi there,
If you're looking for a scripting-free solution and okay with using Graph Builder, it actually handles multi-level spec limits by category — just make sure your spec limits are structured accordingly (e.g., via column property).
If you specifically want to stay with Variability Chart, this behavior isn’t built-in in core JMP — but it is supported in YieldOptiX, a plugin developed for test data analysis. It adds support for category-based spec limits directly in the Variability Chart.
So both options (Graph Builder or Variability Chart with grouped limits) are supported depending on your preferred interface — just depends on what fits your process best.
Re: How do I define spec limits by data category in variability chartHi Jarmo
When I key multiple data, the spec limit does not follow script content. How could I modify script ?
Re: How do I define spec limits by data category in variability chartYou have to calculate the group counts in different manner. One quite simple option could be to add new column to your dt which combines leg and layer
dt << new column("LEGLAYER", Character, Nominal, Formula(:Leg ||:Layer));
then use that in the summary
dt_summary = dt << Summary(
Group(:SampleGroup),
Max(:LSL),
//Mean(:Target),
Min(:USL),
N Categories(:LEGLAYER),
Freq("None"),
Weight("None"),
statistics column name format("column"),
Link to original data table(0)
);
and get the curcount from that
curcount = Sum(dt_summary[i, {"LEGLAYER"}]);

Re: How do I define spec limits by data category in variability chartI used script that you shared, but spec limit is not displayed.
Please help check script as attachments, how to modify it?