## Plotting Functions in Graph Builder

Super User

Joined:

Jun 23, 2011

Trying to plot some functions vs date in graph builder and I get a stepped appearance.  JMP 11 or 12.  Any way to smooth out the curves?  These are bio-rhythms, by the way.

Here's the code:

dt = New Table( "BR-2015", Add Rows( 2 ),

New Column( "Date", Numeric, Continuous, Format( "ddMonyyyy", 18 ),

Input Format( "ddMonyyyy" ),

Set Values( [3502915200, 3518467200] ) ),

New Column( "Physical", Numeric, Continuous, Format( "Best", 12 ),

Formula( bd1 = Parse Date( "01Jan1976" ); t1 = Date Difference( bd1, :Date, "Day" );

Sin( (2 * 3.14159 * t1) / 23 ); ) ),

New Column( "Emotional", Numeric, Continuous, Format( "Best", 12 ),

Formula( bd2 = Parse Date( "01Jan1976" ); t2 = Date Difference( bd2, :Date, "Day" );

Sin( (2 * 3.14159 * t2) / 28 ); ) ),

New Column( "Intellectual", Numeric, Continuous, Format( "Best", 12 ),

Formula( bd3 = Parse Date( "01Jan1976" ); t3 = Date Difference( bd3, :Date, "Day" );

Sin( (2 * 3.14159 * t3) / 33 ); ) ),

New Column( "Composite", Numeric, Continuous, Format( "Best", 12 ),

Formula( :Physical + :Emotional + :Intellectual ) )

);

// Plot formulas as functions

dt << Graph Builder(

Size( 739, 500 ),

Show Control Panel( 0 ),

Variables(

X( :Date ),

Y( :Physical ),

Y( :Emotional, Position( 1 ) ),

Y( :Intellectual, Position( 1 ) ),

Y( :Composite, Position( 1 ) )

),

Elements( Formula( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 3 ) ) )

);

1 ACCEPTED SOLUTION

Accepted Solutions

Community Manager

Joined:

Jun 23, 2011

Solution

In this case the step function is caused by your function which has a built-step at each day because of your Date Difference().

Change the increment for Date Difference to "Hour" and divide by (23*24) you'll get a smoother version. I've only done the Physical for this example.

`dt =New Table("BR-2015", Add Rows(2),    New Column( "Date", Numeric, Continuous, Format( "ddMonyyyy", 18 ),        Input Format( "ddMonyyyy" ),        Set Values( [3502915200, 3518467200] ) ),    New Column( "Physical", Numeric, Continuous, Format( "Best", 12 ),        Formula( bd1 = Parse Date( "01Jan1976" ); t1 = Date Difference( bd1, :Date, "Hour" );        Sin( (2 * 3.14159 * t1) / (23*24) ); ) ),    New Column( "Emotional", Numeric, Continuous, Format( "Best", 12 ),        Formula( bd2 = Parse Date( "01Jan1976" ); t2 = Date Difference( bd2, :Date, "Day" );        Sin( (2 * 3.14159 * t2) / 28 ); ) ),    New Column( "Intellectual", Numeric, Continuous, Format( "Best", 12 ),        Formula( bd3 = Parse Date( "01Jan1976" ); t3 = Date Difference( bd3, :Date, "Day" );        Sin( (2 * 3.14159 * t3) / 33 ); ) ),    New Column( "Composite", Numeric, Continuous, Format( "Best", 12 ),        Formula( :Physical + :Emotional + :Intellectual ) ));// Plot formulas as functionsdt << Graph Builder(    Size( 739, 500 ),    Show Control Panel( 0 ),    Variables(        X( :Date ),        Y( :Physical ),        Y( :Emotional, Position( 1 ) ),        Y( :Intellectual, Position( 1 ) ),        Y( :Composite, Position( 1 ) )    ),    Elements( Formula( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 3 ) ) ));`
-Jeff
2 REPLIES

Community Manager

Joined:

Jun 23, 2011

Solution

In this case the step function is caused by your function which has a built-step at each day because of your Date Difference().

Change the increment for Date Difference to "Hour" and divide by (23*24) you'll get a smoother version. I've only done the Physical for this example.

`dt =New Table("BR-2015", Add Rows(2),    New Column( "Date", Numeric, Continuous, Format( "ddMonyyyy", 18 ),        Input Format( "ddMonyyyy" ),        Set Values( [3502915200, 3518467200] ) ),    New Column( "Physical", Numeric, Continuous, Format( "Best", 12 ),        Formula( bd1 = Parse Date( "01Jan1976" ); t1 = Date Difference( bd1, :Date, "Hour" );        Sin( (2 * 3.14159 * t1) / (23*24) ); ) ),    New Column( "Emotional", Numeric, Continuous, Format( "Best", 12 ),        Formula( bd2 = Parse Date( "01Jan1976" ); t2 = Date Difference( bd2, :Date, "Day" );        Sin( (2 * 3.14159 * t2) / 28 ); ) ),    New Column( "Intellectual", Numeric, Continuous, Format( "Best", 12 ),        Formula( bd3 = Parse Date( "01Jan1976" ); t3 = Date Difference( bd3, :Date, "Day" );        Sin( (2 * 3.14159 * t3) / 33 ); ) ),    New Column( "Composite", Numeric, Continuous, Format( "Best", 12 ),        Formula( :Physical + :Emotional + :Intellectual ) ));// Plot formulas as functionsdt << Graph Builder(    Size( 739, 500 ),    Show Control Panel( 0 ),    Variables(        X( :Date ),        Y( :Physical ),        Y( :Emotional, Position( 1 ) ),        Y( :Intellectual, Position( 1 ) ),        Y( :Composite, Position( 1 ) )    ),    Elements( Formula( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 3 ) ) ));`
-Jeff

Super User

Joined:

Jun 23, 2011

Thanks Jeff that works great.