Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Cholesterol Stacked.jmp");
dt << New Column("NegLimit", Numeric, Continuous, Formula(
Col Mean(:Y, :Treatment) - 4 * Col Std Dev(:Y, :Treatment)
));
dt << New Column("PosLimit", Numeric, Continuous, Formula(
Col Mean(:Y, :Treatment) + 4 * Col Std Dev(:Y, :Treatment)
));
dt << New Column("MarkerVal", Numeric, Continuous, Formula(
If(!IsMissing(Days),
.
, Row() == Col Min(Row(), :Treatment, :Days),
:NegLimit - 10
,
:PosLimit + 10
)
));
dt << New Column("MarkerLabel", Character, Continuous, Label(1), Formula(
If(!IsMissing(Days),
.
, Row() == Col Min(Row(), :Treatment, :Days),
"-4Sigma " || Char(Round(:NegLimit, 2))
,
"+4Sigma " || Char(Round(:PosLimit, 2))
)
));
Summarize(dt, uniq_treatments = by(:Treatment));
rows_added = 0;
For Each({cur_treatment}, uniq_treatments,
dt << Add Rows({Treatment = cur_treatment});
dt << Add Rows({Treatment = cur_treatment});
rows_added = rows_added + 2;
);
dt << Select Rows((N Rows(dt) - rows_added + 1)::N Rows(dt)) << Label(1) << Clear Select;
gb = dt << Graph Builder(
Size(1126, 772),
Show Control Panel(0),
Variables(
Y(:Y, Combine("Merged")),
Y(:NegLimit, Position(1), Combine("Merged")),
Y(:PosLimit, Position(1), Combine("Merged")),
Y(:MarkerVal, Position(1), Combine("Merged")),
Group X(:Treatment)
),
Elements(
Line(
Y(2),
Y(3),
Legend(7),
Fill("Fill Between"),
Missing Factors("Treat as Missing"),
Missing Values("Connect Faded")
),
Points(Y(1), Legend(5)),
Points(Y(4), Legend(11))
),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
7,
Properties(0, {Line Color(16)}, Item ID("Mean(NegLimit)", 1)),
Properties(1, {Line Color(16)}, Item ID("Mean(PosLimit)", 1)),
Properties(
2,
{Fill Color(37)},
Item ID("Mean(NegLimit)..Mean(PosLimit)", 1)
)
), Legend Model(
11,
Properties(
0,
{Line Color(0), Marker(" "), Marker Size(0)},
Item ID("MarkerVal", 1)
)
)}
),
Dispatch(
{},
"400",
LegendBox,
{Legend Position({7, [1, 2, 3], 5, [0], 11, [4]})}
)
)
);