The second problem with the light and dark phase lines not showing up where expected is due to a mismatch between the axis variable and the variable used to define where the lines should go.
In the graph the x axis is a duration and in the custom script the lines are based on the row number, so graph builder uses the row number and plots it on the time duration, which kind of just doesn't work.
I added a couple of columns to the data table, they are similar to some of the original columns, but with some small tweaks and formatting differences.
//if you have the data table open, make it the active table and run this
dt=current data table();
dt<<New Column( "Time 2",
Numeric,
"Continuous",
Format( ":day:hr:m", 14 ),
Input Format( ":day:hr:m" ),
Formula( :DateTime - :StartTime ),
Set Selected
);
dt<<New Column( "step2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( If( :Phase == "Dark phase", 0, 1 ) ),
Set Selected
);
dt<<New Column( "phase2",
Character,
"Nominal",
Formula( If( :Phase == "Dark phase", "D", "L" ) )
);
The next step is to edit the custom script in the graph.
//This script goes into the Custom Script in the graph builder plot
For Each Row( If( Is Missing( :NewPhase ) == 0, V Line( :Time2 ) ) );
For Each Row(
If( Is Missing( :NewPhase ) == 0,
Text( {:Time2, 5 + :step2}, " "||:Phase2 )
)
);
//The, " "||:phase2, inserts a space before the label so that it isn't touching the phase line.
The result is the fixed graph, like this.
With all the changes, the x-axis is now in Days:Hours:minutes format, and all the light and dark phase lines show up in the right place. The phase label is abbreviated so that it doesn't overlap and just make a jumble off messy text.
Graph script
Graph Builder(
Size( 1455, 290 ),
Show Control Panel( 0 ),
Variables( X( :Time2 ), Y( :Name( "EE-[kcal/h]" ) ), Overlay( :Treatment ) ),
Elements( Line( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"Time2",
ScaleBox,
{Min( -586333.5 ), Max( 2531060.48337292 ), Interval( "Day" ), Inc( 1 ),
Minor Ticks( 6 ), Label Row( Label Orientation( "Perpendicular" ) )}
),
Dispatch(
{},
"EE-[kcal/h]",
ScaleBox,
{Format( "Best", 12 ), Min( 1.7751677852349 ), Max( 5.7751677852349 ),
Inc( 1 ), Minor Ticks( 0 )}
),
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script(
2,
Description( "Script" ),
For Each Row( If( Is Missing( :NewPhase ) == 0, V Line( :Time2 ) ) );
For Each Row(
If( Is Missing( :NewPhase ) == 0,
Text( {:Time2, 5 + :step2}, " " || :Phase2 )
)
);
), Grid Line Order( 1 ), Reference Line Order( 3 ),
DispatchSeg(
TopSeg( 1 ),
{Set Script(
For Each Row(
If( Is Missing( :NewPhase ) == 0,
V Line( :Time2 )
)
);
For Each Row(
If( Is Missing( :NewPhase ) == 0,
Text( {:Time2, 5 + :step2}, " " || :Phase2 )
)
);
)}
)}
)
)
)
JMP Systems Engineer, Health and Life Sciences (Pharma)