You can loop over the return result from the original Variability Chart( By( ... ) )
command:
names default to here(1);
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Cars.jmp" );
rpt = dt << Variability Chart(
Y( :Head IC),
X( :Make, :Model ),
Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
By( :NAME("D/P"), :Protection ),
);
//find groupings:
subt = dt << Summary( Group( :"D/P"n, :Protection ), Link to Original Data Table( 0 ) );
dps = subt:"D/P"n << Get Values;
protections = subt:protection << Get Values;
Close( subt, No Save );
For( t = 1, t <= N Items( dps ), t++,
Eval( eval Expr(
rows = dt << Get Rows Where( :NAME("D/P") == Expr( dps[t] ) & :Protection == Expr( protections[t] ) );
) );
subt = dt << Subset( Rows( rows ), Columns( :Make, :Model, :Wt ), Not Linked, Private );
sumt = subt << Summary( Group( :Make, Model ), Mean( :Wt ), Statistics Column Name Format( "Column" ), Link to Original Data Table( 0 ), Private );
Close( subt, No Save );
subt = sumt << Summary( Group( :Make ), Mean( :Wt ), Statistics Column Name Format( "Column" ), Link to Original Data Table( 0 ), Private );
Close( sumt, No Save );
category number = [=>];
category average = [=>];
For Each Row( subt,
category number[:Make] = :N Rows; // each least-significant category in a VariabilityPlot is exactly X=1 width on the hidden x-axis, starting at zero
category average[:Make] = :Wt
);
Close( subt, No Save );
tree = rpt[t] << Report;
Eval( Eval Expr(
tree[FrameBox( 1 )] << Add Graphics Script(
Local( {values = Expr( category average ), numbers = Expr( category number ), i, items, sum = 0},
items = numbers << Get Keys;
Pen Size( 2 );
Pen Color( "Blue" );
Summation( i = 1, N Items( items ),
Line( Eval List( {sum, values[items[i]]} ), Eval List( {sum += numbers[items[i]], values[items[i]]} ) );
0
)
)
)
) )
);
Jordan