Hi all,
I wanted to create a new thread to differentiate based on my previous post: https://community.jmp.com/t5/Discussions/How-to-add-Dynamic-horizontal-line-by-shared-y-axis-among/m.... The same idea is to be applied where I would want a dynamic horizontal line across a variability chart, but unlike the previous solution that uses an associative array as there is one value per x, this case potentially has multiple values per x grouping in which graphing based on N per x doesn't work as the N is split between conditions and has to be drawn as such. This is where I am struggling to figure out how to do that and would appreciate someone with more graph scripting experience to aid if possible. Below is the desired output with hand drawn lines for example and the code for generating the graph is below as well.
In the example below, Toyota is now split among :Protection in which there is N=8 and N=3 and likewise Ford is N=11 and N=3 for the groupings and I would like to ensure that both Toyota groups and Ford groups among others have a horizontal line with the value of Max(:Wt) as shown by the red and blue lines and all other's have an equally unique line as shown by the purple lines. Any idea of how to accomplish that would be fantastic. At the bottom of the post, the code given by @ErraticAttack is posted as a wonderful template for grouping and graphing but since its an associative array it would say Toyota is N: 8+3 = 11 and likewise Ford is 11+3=14 wide and graph the ranges wrong as they are now split up.
dt = Open( "$SAMPLE_DATA/Cars.jmp" );
rpt = dt << Variability Chart(
Y( :Head IC),
X( :Protection, :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")),
);
@ErraticAttack 's code to aid my previous question.
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 ),
Where( :NAME("D/P") == "Driver" & :Protection == "manual belts" ),
);
//find groupings:
rows = dt << Get Rows Where( :NAME("D/P") == "Driver" & :Protection == "manual belts" );
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 << 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
)
)
)
) )
Thank you, truly appreciate any help!