cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
yfu23
Level II

Is there a way to automatically draw ref lines at the peak of curve in a plot?

How do I darw a line at the peak of the curve without manually seraching for the peak?

 

Untitled.jpg

6 REPLIES 6
yfu23
Level II

Re: Is there is way to automatically draw ref lines at the peak of my curve in a plot?

Correction- How do I darw a line at the peak of the curve without manually seraching for the peak?

txnelson
Super User

Re: Is there is way to automatically draw ref lines at the peak of my curve in a plot?

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.

reflines.PNG

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
Craige_Hales
Super User

Re: Is there is way to automatically draw ref lines at the peak of my curve in a plot?

yfu23
Level II

Re: Is there is way to automatically draw ref lines at the peak of my curve in a plot?

When I have multiple overlay plots in a report. How do I individually extract data table from each plot?

yfu23
Level II

Re: Is there is way to automatically draw ref lines at the peak of my curve in a plot?

I don't actually see the ref lines drawn. But I get the idea to use summary to find min, max, mean, etc.

I am using JMP12 and making babe steps.

 

Untitled.jpg

Craige_Hales
Super User

Re: Is there is way to automatically draw ref lines at the peak of my curve in a plot?

Check the log window, the message suggests this needs a tweak:

 

theXMax = dt:X[(dt << get rows where( :group == Num( bygroup[i] ) & :Y == theYMax[i] ))[1]];

Craige