You can determine the peak by finding the Max value for each group, then find the X value by finding the row that the Max value is found.
Here is an example of the output and the simple script that creates the reference lines.
and here is the script
Names Default To Here( 1 );
dt = New Table( "Example",
Add Rows( 130 ),
New Script( "Source", Data Table( "Untitled 25" ) << Sort( By( :Group, :Y ), Order ) ),
New Column( "Group",
Numeric,
"Ordinal",
Format( "Best", 12 ),
Set Values(
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13]
)
),
New Column( "Y",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[1, 2, 3, 6, 7, 7, 8, 8, 8, 10, 1, 2, 2, 3, 5, 5, 6, 7, 8, 10, 1, 3, 3, 5, 6, 7, 8,
10, 10, 10, 2, 3, 3, 3, 4, 4, 7, 9, 9, 9, 1, 1, 2, 3, 6, 6, 7, 8, 8, 10, 1, 1, 3, 3,
3, 4, 6, 6, 8, 8, 2, 3, 4, 5, 5, 7, 9, 9, 10, 10, 2, 2, 2, 4, 5, 6, 7, 9, 10, 10, 1,
1, 2, 3, 3, 4, 8, 9, 9, 10, 1, 3, 3, 4, 4, 4, 4, 7, 8, 10, 2, 3, 4, 5, 6, 7, 8, 8, 8,
9, 2, 5, 5, 6, 7, 8, 8, 9, 10, 10, 2, 3, 4, 4, 6, 6, 8, 8, 9, 9]
)
),
New Column( "X",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[1, 2, 3, 4, 5, 6, 10, 9, 7, 8, 1, 2, 3, 4, 5, 6, 10, 9, 7, 8, 1, 2, 3, 4, 5, 6, 10,
9, 7, 8, 1, 2, 3, 4, 5, 6, 10, 9, 7, 8, 1, 2, 3, 4, 5, 6, 10, 9, 7, 8, 1, 2, 3, 4, 5,
6, 10, 9, 7, 8, 1, 2, 3, 4, 5, 6, 10, 9, 7, 8, 1, 2, 3, 4, 5, 6, 10, 9, 7, 8, 1, 2,
3, 4, 5, 6, 10, 9, 7, 8, 1, 2, 3, 4, 5, 6, 10, 9, 7, 8, 1, 2, 3, 4, 5, 6, 10, 9, 7,
8, 1, 2, 3, 4, 5, 6, 10, 9, 7, 8, 1, 2, 3, 4, 5, 6, 10, 9, 7, 8]
)
)
);
// Create the graph
gb = Graph Builder(
Variables( X( :X ), Y( :Y ), Overlay( :Group ) ),
Elements( Points( X, Y, Legend( 9 ) ), Line( X, Y, Legend( 11 ) ) )
);
// Find the number of groups and their max
Summarize( dt, bygroup = by( :group ), theYMax = Max( :Y ) );
// Loop across the groups and create reference lines for the max Y found in each group
For( i = 1, i <= N Items( bygroup ), i++,
theXMax = dt:X[(dt << get rows where( :group == Num( bygroup[i] ) & :Y == theMax[i] ))[1]];
Eval(
Substitute(
Expr(
Report( gb )[AxisBox( 1 )] << add ref line( __x__ );
Report( gb )[AxisBox( 2 )] << add ref line( __y__ );
),
Expr( __x__ ), theXMax,
Expr( __y__ ), theYMax[i]
),
);
);
Jim