Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
speleogen
Level I

How to plot a normal curve on a histogram

Back in 2017, txnelson posted a nice snippet of code to do this:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

Dis = dt << Distribution(
	Continuous Distribution( Column( :height ), Vertical( 0 ), Density Axis( 1 ) )
);

Report( Dis )[Frame Box( 2 )] << Add Graphics Script(
	mu = 63;
	sigma = 3.2;
	Pen Color( "Red" );
	Y Function( Normal Density( (x - mu) / sigma ) / (40 / 12), x );

	mu = 51.5;
	sigma = .87;
	Pen Color( "Blue" );
	Y Function( Normal Density( (x - mu) / sigma ) / (40 / 2), x );
);

To scale the curve properly, you need the total number of data points divided by the data points for the maximum bar in the histogram distribution (here shown as 40/12 and 40/2) . Is there a way to calculate these? I can get the former, but not the latter.

 

Thanks for any help,

John

1 REPLY 1
Highlighted

Re: How to plot a normal curve on a histogram

I do not know how to get the counts but assuming that the scale is appropriate, you could ask the Axis Box for the Maximum scale value with the << Get Max message.

Learn it once, use it forever!
Article Labels

    There are no labels assigned to this post.