Hello,
I am trying to use JSL to show different reference lines for each group in a variability chart. The following picture is the end result I am looking for (done manually, not using JSL): I created 6 separate variability charts, one for each group, each with its own ref. lines (pictures 2 to 7), then dragged the contents of each chart to the 1st chart using the Selection tool get the overall chart.
Can this be scripted, and if so using which command & syntax ?
Alternatively, can reference lines be added to a Variability chart for specific groups, as opposed to having the ref. line run all the way across the chart?
Group-wise partial reference lines can be simulated with a graphics script. Below is an attempt that certainly can be further improved. Currently the reflines are connected giving an impression of an step function (which may or may not be desirable).
dt = Open("$SAMPLE_DATA/Big Class.jmp");
vc = dt << Variability Chart(Y(:height), X(:age), Std Dev Chart(0));
// Define reflines;
// In this example they are quartiles but could be any custom list
Summarize(g = by(dt:age), ref = Quantile(dt:height, 0.25));
//Build and eval graphics script expression
lineexpr = Expr(Line());
For(i = 1, i <= N Items(g), i++,
Insert Into(lineexpr, Eval List({i - 1, ref[i]}));
Insert Into(lineexpr, Eval List({i, ref[i]}));
);
Eval(
Eval Expr(
Report(vc)[framebox(1)] << add graphics script(
Line Style("Dotted");
Pen Color("red");
Expr(Name Expr(lineexpr));
)
)
);
Group-wise partial reference lines can be simulated with a graphics script. Below is an attempt that certainly can be further improved. Currently the reflines are connected giving an impression of an step function (which may or may not be desirable).
dt = Open("$SAMPLE_DATA/Big Class.jmp");
vc = dt << Variability Chart(Y(:height), X(:age), Std Dev Chart(0));
// Define reflines;
// In this example they are quartiles but could be any custom list
Summarize(g = by(dt:age), ref = Quantile(dt:height, 0.25));
//Build and eval graphics script expression
lineexpr = Expr(Line());
For(i = 1, i <= N Items(g), i++,
Insert Into(lineexpr, Eval List({i - 1, ref[i]}));
Insert Into(lineexpr, Eval List({i, ref[i]}));
);
Eval(
Eval Expr(
Report(vc)[framebox(1)] << add graphics script(
Line Style("Dotted");
Pen Color("red");
Expr(Name Expr(lineexpr));
)
)
);
Thanks MS,
I can see how this works now and I tweaked your script to not connect the ref. lines between groups. The way I scripted is not elegant, but it is functional. I will refine my script later to make the ref. lines table variables and add a for loop, like in your example.
dt = Open("$SAMPLE_DATA/Big Class.jmp");
vc = dt << Variability Chart(Y(:height), X(:age), Std Dev Chart(0));
// Define reflines;
//Build and eval graphics script expression
lineexpr1 = Expr(Line());
Insert Into(lineexpr1, Eval List({0, 55}));
Insert Into(lineexpr1, Eval List({1, 55}));
lineexpr2 = Expr(Line());
Insert Into(lineexpr2, Eval List({1, 60}));
Insert Into(lineexpr2, Eval List({2, 60}));
lineexpr3 = Expr(Line());
Insert Into(lineexpr3, Eval List({2, 65}));
Insert Into(lineexpr3, Eval List({3, 65}));
Eval(
Eval Expr(
Report(vc)[framebox(1)] << add graphics script(
Line Style("Dotted");
Pen Color("red");
Expr(Name Expr(lineexpr1));
Line Style("Dotted");
Pen Color("red");
Expr(Name Expr(lineexpr2));
Line Style("Dotted");
Pen Color("red");
Expr(Name Expr(lineexpr3));
)
)
);