cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
BHarris
Level VI

Background reference plot in Graph Builder

Suppose I have a baseline data set of the growth rate of bacteria A over time at room temperature and 40% humidity.

 

Then I run an experiment on bacteria B where I vary the temperature and humidity levels to see how those affect the growth rate, wanting to see them relative to bacteria A.

 

My columns are:  bacteriaType, temp, humidity, time, growthRate

 

I'd like to do this:  time -> X, growthRate -> Y, temp -> groupX, humidity -> groupY, and bacteriaType -> Overlay

 

... and have the reference data (bacteria A) be plotted on every plot behind the bacteria B data.  But I don't have it for every temperature and humidity level.

 

Is there a way to do this?

9 REPLIES 9
txnelson
Super User

Re: Background reference plot in Graph Builder

Given your description, the base reference bacteria, bacteria a will be displayed on every graph that you have data for that combination of factors.  If your question is, how do you get the base level a bacteria to show up in every graph, it is just a matter of replicating the growth rate data and time data for the combinations of factors that are missing.

 

I hope I am understanding what your want.  If not, please tell me what I am not getting.

Jim
BHarris
Level VI

Re: Background reference plot in Graph Builder

Yep, you got it.

 

I was hoping to not have to replicate the same data for bacteria A 25 times to make it show up in each graph...

 

I wondered if there was a script I could use to generate the same plot, similar to how you can draw shapes into the plot windows with "Customize Graph", then adding a "script"?

 

Or if there was some way to have it assume that a given row/record should be plotted in the current plot if there is *no* data in the corresponding field as well as if the field matches the value represented by the column of plots?

 

Thx.

ih
Super User (Alumni) ih
Super User (Alumni)

Re: Background reference plot in Graph Builder

It sounds daunting but replicating the data is can be done fairly quickly by joining the growth data to a table of the available options using a 'cartesian join' and then concatenating it to your original data.  Here is an example

 

View more...
names default to here(1);

dtResults = New Table( "Results",
	Add Rows( 240 ),
	New Column( "time",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Mod( Row() - 1, 10 ) )
	),
	New Column( "humidity",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Sequence( 30, 60, 10, 60 ) ),
		Set Selected
	),
	New Column( "Bacteria Type",
		Character,
		"Nominal",
		Value Labels( {"1" = "a", "2" = "b"} ),
		Use Value Labels( 1 ),
		Set Values( Repeat( {"b"},240) )
	),
	New Column( "magnitude",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :time == 0, Random Uniform( 0.5, 1 ), Lag( :magnitude ) ) )
	),
	New Column( "temp",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Sequence( 80, 90, 2, 10 ) )
	),
	New Column( "growthRate",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			If( :time == 0,
				0,
				(1 - :time / (:time + 1)) * Ln( :time * 2 ) * :magnitude * :humidity
				 * :temp + Random Normal( 0, 100 )
			)
		)
	)
);


dtRef = New Table( "Reference",
	Add Rows( 10 ),
	New Column( "time",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Row() - 1 )
	),
	New Column( "growthRate",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			If( :time == 0,
				0,
				(1 - :time / (:time + 1)) * Ln( :time * 2 ) * 0.7 * 40 * 80
				+Random Normal( 0, 100 )
			)
		)
	),
	New Column( "Bacteria Type",
		Character,
		"Nominal",
		Set Selected,
		Set Values( {"a", "a", "a", "a", "a", "a", "a", "a", "a", "a"} )
	)
);

dtAll = New Table( "All Conditions",
	Add Rows( 24 ),
	New Column( "temp",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Sequence( 80, 90, 2 ) )
	),
	New Column( "humidity",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Sequence( 30, 60, 10, 6 ) ),
		Set Selected
	),
	Set Row States(
		[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	)
);

wait(1);

dtRefAll = dtRef << Join(
	With( dtAll ),
	Cartesian Join,
	Copy formula(1)
);
dtRefAll << Set Name( "All Reference Data" );

dtForGraph = dtResults << Concatenate( dtRefAll, Keep Formulas );
dtForGraph << Set Name("For Graphing");

dtForGraph << Graph Builder(
	Size( 676, 633 ),
	Show Control Panel( 0 ),
	Variables(
		X( :time ),
		Y( :growthRate ),
		Group X( :temp ),
		Group Y( :humidity ),
		Overlay( :Bacteria Type )
	),
	Elements( Points( X, Y, Legend( 10 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				10,
				Properties( 0, {Line Color( 32 )}, Item ID( "a", 1 ) ),
				Properties( 1, {Line Color( 56 )}, Item ID( "b", 1 ) )
			)}
		),
		Dispatch( {}, "400", LegendBox, {Set Title( "Bacteria" )} )
	)
);
BHarris
Level VI

There's a function called "Y Function()" that lets me plo...

There's a function called "Y Function()" that lets me plot directly into each plot in Graph Builder using the "Customize Graph" window, which is super cool...

 

Is there a similar function that will let me plot data from the main data table via that same interface?  That would solve my problem without requiring me to create a data table that's significantly larger.

txnelson
Super User

Re: There's a function called "Y Function()" that lets me plo...

The Customize option that is available from graphs in JMP is an interface into JMP's ability to use JSL to use base level graphic routines to add to the display.  Here is a simple example taken from the Scripting Index.

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( Y( :weight ), X( :height ), FitLine );
rbiv = biv << report;
framebox = rbiv[frame box( 1 )];
framebox << Add Graphics Script(
	Transparency( 0.5 );
	Fill Color( {1.0, 0.5, 0.0} );
	Polygon( [60, 72, 57], [75, 120, 120] );
);

 add1.PNG

The Y Function() is just one of the graphic primitives that are available to add to any displayed graph.  Or, one can also write to a display object called Graph Box() and generate an original, stand alone graphical display. 

All of these graphical functions are documented in the Scripting Index, under "Graphics"

add2.PNG
 So to answer you question, 

Yes, you could add JSL to each of your graphs that would read from the original data table and plot the values.  One would just have to write the JSL to take the values from the data table and use the Marker, Pen Color, Line, etc. functions to build the graphical display.

Jim
txnelson
Super User

Re: There's a function called "Y Function()" that lets me plo...

Here is a simple example of taking a reference group(age 12 individuals) and graphing their data on to all graphs produced.

add3.PNG

This is the graph for the 13 year old's, with the 12 year old's data displayed with the squares.

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

// Get the values to be displayed on all graphs
theRows = dt << get rows where( :Age == 12);
	xMat = :height[theRows];
	yMat = :weight[theRows];
	
// Create the graph
biv = dt << Bivariate( Y( :weight ), X( :height ), FitLine, by(:age) );

// Add the data to each graph produced
rbiv = biv << report;
(rbiv << xpath( "//FrameBox" )) << Add Graphics Script(	
	marker( marker state(3), xMat, yMat);
);
Jim

Re: There's a function called "Y Function()" that lets me plo...

One caution about @txnelson's solution. It demonstrates the JSL capability that you asked about well. However, using variables in a graphics script can lead to unexpected and undesirable behavior. For example, such a script might break if you journal this window.

 

This concern depends on the larger context of your analysis plan.

ih
Super User (Alumni) ih
Super User (Alumni)

Re: There's a function called "Y Function()" that lets me plo...

@Mark_Bailey, would evaluating those variables first eliminate the behavior you mention, for example by replacing the last lines of @txnelson's script with this this?

 

Eval( Eval expr( 
	(rbiv << xpath( "//FrameBox" )) << Add Graphics Script(	
		marker( marker state(3), Expr( xMat ), Expr( yMat ) );
	)
) );

 

 

Re: There's a function called "Y Function()" that lets me plo...

Yes, that is my suggestion.