Maybe something like this
dtBigClass = Open( "$sample_data/big class.jmp" );
dtage = dtBigClass << Summary( Group( :age ) ); // makes a small table of unique ages
ages = dtage[0, 1]; // [12, 13, 14, 15, 16, 17]
Close( dtage, "nosave" ); // table no longer needed
grid = Lineup Box( N Col( 3 ), spacing( 20, 30 ) ); // Horz,Vert extra space between graphs in pixels
For( iAge = 1, iAge <= N Rows( ages ), iAge += 1, // for each age...
dtBigClass << selectwhere( age == ages[iAge] );
dtSubset = dtBigClass << subset( selectedrows( 1 ), linked( 1 ), "invisible" );
// the summary will be a single row with the requested information
dtSummary = dtSubset << Summary( Mean( :height ), Mean( :weight ), Std Dev( :height ), Std Dev( :weight ), Freq( "None" ), Weight( "None" ) );
// grab the values of interest in simpler variable names
heightMean = dtSummary:name( "Mean(height)" )[1]; // row one has the answers
heightStdDev = dtSummary:name( "Std Dev(height)" )[1];
weightMean = dtSummary:name( "Mean(weight)" )[1];
weightStdDev = dtSummary:name( "Std Dev(weight)" )[1];
Close( dtSummary, "nosave" ); // close the work table, no longer needed
// make a graph, attach to a borderbox so it does not open in a window...
bb = Border Box(
dtSubset << Graph Builder(
Size( 400, 300 ),
Show Control Panel( 0 ),
Show Legend( 0 ), // don't need a legend
Variables( X( :height ), Y( :weight ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
// add ref lines. You can get a script like this GraphBuilder script by
// making a graph builder interactively, then using the red triangle->get script.
// below, the numbers in the script have been replaced with the variables above.
SendToReport(
Dispatch(
{},
"height",
ScaleBox,
{Add Ref Line( heightMean, "Dotted", "Red", "", 2 ), Add Ref Line( heightMean + heightStdDev, "Dotted", "Blue", "", 2 ),
Add Ref Line( heightMean - heightStdDev, "Dotted", "Blue", "", 2 ),
// force all axes to be the same...
Min( 48.2828947368421 ), Max( 75.8776488919668 ), Inc( 5 ), Minor Ticks( 1 )}
),
Dispatch(
{},
"weight",
ScaleBox,
{Add Ref Line( weightMean, "Dotted", "Red", "", 2 ), Add Ref Line( weightMean + weightStdDev, "Dotted", "Blue", "", 2 ),
Add Ref Line( weightMean - weightStdDev, "Dotted", "Blue", "", 2 ),
// force all axes to be the same...
Min( 55.2100840336134 ), Max( 188.127074359155 ), Inc( 20 ), Minor Ticks( 0 )}
),
Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 6 ), Transparency( 1 )} ), // make the markers bigger
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Age = " || Char( ages[iAge] ) )} ), // add the age= title
Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "" )} ) // suppress the Graph Builder title
)
)
);
grid << append( bb ); // add the graph to the grid
); // the iAge loop
dtBigClass << clearRowStates; // undo the final selection
New Window( "the report", V List Box( H Center Box( Text Box( "Big Report", <<setFontSize( 20 ) ) ), grid ) );
Reports grouped in a 3-wide grid
Craige