I am new to creating scripts and having trouble creating one that labels the peaks and valleys on the data.
The goal is to actually label all valleys after the first Peak is detected. I am trying to simplify it by creating a script that graphs the data and labels all peaks and valleys to allow easier data analysis by my team. Tried to follow past instructions and it seems I just can't get it to work.
I have tried to explore all existing solutions for this but had trouble implementing a solution that worked for me.
Your data seems to have character data type which at least requires changing the data to numeric/continuous. Could you use your data, create a plot and mark what you are interested in finding/detecting. Usually you can find peaks/valleys using some combination of Lag/Dif and maybe some if statements

dt = Open( "$DESKTOP/Sample.jmp" );
max_value = Col Maximum(Column(dt, "Heat"));
total_rows = N Row(dt);
Time_col = Column(dt, "Heat");
row_num = 0;
For(i = total_rows, i >= 1, i--,
If(Time_col[i] == max_value,
row_num = i;
Break();
)
);
max_time = :Time[row_num];
col_data = Column(dt, "Heat") << Get Values;
min_data = col_data[row_num::total_rows];
min_value = Minimum(min_data);
min_positions = loc min(min_data);
min_time_col = min_positions + (row_num - 1);
min_time = :Time[min_time_col];
Graph Builder(
Size( 1032, 646 ),
Show Control Panel( 0 ),
Fit to Window( "Off" ),
Variables( X( :Time ), Y( :Heat ) ),
Elements( Line( X, Y, Legend( 14 ) ) ),
SendToReport(
Dispatch( {}, "Time", ScaleBox,
{Format( "Best", 12 ), Min( 1.88 ), Max( 5.07800951567129 ), Inc( 0.5 ),
Minor Ticks( 4 ), Add Ref Line(
max_time,
"Dotted",
"Black",
Char(max_time),
2,
1,
Label Settings( {Label Color( "Red" )} )
), Add Ref Line(
min_time,
"Dotted",
"Black",
Char(min_time),
2,
1,
Label Settings( {Label Color( "Red" )} )
)}
),
Dispatch( {}, "Heat", ScaleBox,
{Add Ref Line(
max_value,
"Dotted",
"Black",
Char(max_value),
2,
1,
Label Settings( {Label Color( "Red" )} )
), Add Ref Line(
min_value,
"Dotted",
"Black",
Char(min_value),
2,
1,
Label Settings( {Label Color( "Red" )} )
)}
)
)
);
Is there something that isn't being done by that script?
Thank you for taking the time to share this code! I am running into a problem where when I run the same script the chart that is generated is very different. what am I doing wrong?
If you use the sample table provided it won't work unless you fix the column data types to numeric and modeling types to continuous. My guess is that you didn't do the modeling type conversion.
Thank you, after updating everything the chart shows a mean line for summary statistic. It now shows the peak and valley so I will try to figure out how to make the line show the actual data.
I got everything to work, accepted as solution. However when I try to do chart builder it keeps making the line a mean. I'm assuming something in the script is causing this. Can anyone support in addressing this issue?
It will use mean line because you have multiple measurements happening exactly at the same time.
Edit: Make sure your data is ordered correctly and then use Row order

This way it shouldn't be using summary statistics and will order the data on x-axis based on the row order of your table
Thank you, the solution was to ensure all data columns were labeled as numeric and continuous. Thank you all for your patience while helping me.