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

Conditional Bivariate Fit Customization Script Based on Group By Column

Hi, I am relatively new to JMP and am using the bivariate plot platform to generate a list of bivariate plots from a dataset. I started using an auto-generated JSL script to add identical axis and legend settings to all plots as seen below:

Bivariate(
	Y( :PeakValue ),
	X( :"Duration (s)"n ),
	By( :Checker Name ),
	SendToReport(
		Dispatch(
			{},
			"Duration (s)",
			ScaleBox,
			{Scale( "Log" ), Format( "Engineering SI", 9 ), Min( 0.0000000001 ),
			Max( 0.001 ), Inc( 1 ), Minor Ticks( 1 ),
			Label Row(
				{Show Major Grid( 1 ), Show Minor Grid( 1 ), Show Minor Labels( 0 )}
			)}
		),
		Dispatch( {}, "PeakValue", ScaleBox, {Label Row( Show Major Grid( 1 ) )} ),
		Dispatch(
			{},
			"Bivar Plot",
			FrameBox,
			{Marker Drawing Mode( "Normal" ),
			Row Legend(
				Corner,
				Color( 1 ),
				Color Theme( "JMP Default"(1) ),
				Marker( 0 ),
				Marker Theme( "" ),
				Continuous Scale( 0 ),
				Reverse Scale( 0 ),
				Excluded Rows( 0 )
			)}
		)
	)
);

 

As you can see above, I am grouping the dataset by the column :Checker Name. However, I wanted to extend this script by also adding transparent Rect() graphics objects to create acceptable ranges to each of the scatterplots. However, the dimensions and location of these Rect() objects will vary depending on which bivariate plot it is being plotted in. In short, I need to create a key of :Checker Name to Rect sizing variables that will be correctly applied depending on the bivariate plot in the set. Is this something easy/plausible to incorporate in the pre-generated script I have above?

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Conditional Bivariate Fit Customization Script Based on Group By Column

I assume you are using JMP18. When you use By you get a list of platforms back and you can then loop over that. Then it is just about figuring out how to get the title and so on (or you can use Summarize and in that case I would build the reference list in a bit different way). If it is difficult to figure out the looping, you can first just create single bivariate platform and get it working, then expand to loops

Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Big Class.jmp");

aa_rect = Associative Array();
aa_rect["M"] = Expr(Rect(80, 60, 120, 55));
aa_rect["F"] = Expr(Rect(90, 65, 140, 55));

bivs = dt << Bivariate(Y(:height), X(:weight), By(:sex));

For Each({cur_biv}, bivs,
	ob = Report(cur_biv)[OutlineBox(1)];
	obtitle = ob << get title;
	show(obtitle);
	category = Word(-1, obtitle, "=");
	fb = ob[FrameBox(1)];
	
	Eval(EvalExpr(
		fb << Add Graphics Script(
			Pen Color("Blue");
			Pen Size(2);
			Expr(aa_rect[category]);
		)
	));
);

jthi_0-1720670698367.png

 

-Jarmo

View solution in original post

5 REPLIES 5
jthi
Super User

Re: Conditional Bivariate Fit Customization Script Based on Group By Column

You can try to do it interactively in JMP (you will most likely have to hard-code the Rect() values to each scatterplot). I would suggest using JSL with a loop.

-Jarmo
jsillman2000
Level I

Re: Conditional Bivariate Fit Customization Script Based on Group By Column

How would you recommend I split up the Bivariate function with By( :Checker Name ) into a loop of Bivariates with unique Checker Names?

 

-Jacob

Re: Conditional Bivariate Fit Customization Script Based on Group By Column

Save the list of references to a variable: biv = Bivariate( ... ). You can iterate over the list. You can either query the outline boxes t determine the By variable level, or use Summarize() function to get a list of the groups. It will be in the same order.

jsillman2000
Level I

Re: Conditional Bivariate Fit Customization Script Based on Group By Column

I'm considering using an associative array to assign a rect object to each possible key in the Checker Name column. Can you provide an example of iterating over a list of outline boxes and adding a rect() object to each one? I am also unfamiliar with the Summarize function.

jthi
Super User

Re: Conditional Bivariate Fit Customization Script Based on Group By Column

I assume you are using JMP18. When you use By you get a list of platforms back and you can then loop over that. Then it is just about figuring out how to get the title and so on (or you can use Summarize and in that case I would build the reference list in a bit different way). If it is difficult to figure out the looping, you can first just create single bivariate platform and get it working, then expand to loops

Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Big Class.jmp");

aa_rect = Associative Array();
aa_rect["M"] = Expr(Rect(80, 60, 120, 55));
aa_rect["F"] = Expr(Rect(90, 65, 140, 55));

bivs = dt << Bivariate(Y(:height), X(:weight), By(:sex));

For Each({cur_biv}, bivs,
	ob = Report(cur_biv)[OutlineBox(1)];
	obtitle = ob << get title;
	show(obtitle);
	category = Word(-1, obtitle, "=");
	fb = ob[FrameBox(1)];
	
	Eval(EvalExpr(
		fb << Add Graphics Script(
			Pen Color("Blue");
			Pen Size(2);
			Expr(aa_rect[category]);
		)
	));
);

jthi_0-1720670698367.png

 

-Jarmo