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
Josee
Level II

Using Column in table as ref line

How can I use a column as reference line to a bivariate table? I have a data table with 4 columns as upper control limit, upper warn limit, lower warn limit and lower control limit. The data table also has a column with many variables. There is a specific value of limits to each variable. I am trying to plot Value vs time by Variable but would like the limits for that specific variable chart added on the y axis. 

 

I attached the big class jmp file as an example  but added made up UCL, CL, and LCL. What I want is to graph weight (my value) vs height (time) by sex (variable) . But would like the UCL, CL and LCL column to show as limits on the y axis to it's appropriate variable chart. Hope this is kinda clear? Any help will be appreciated. 

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Using Column in table as ref line

There is a Discussion Track that has covered this before.  See:

Define UCL/LCL in columns

Jim

View solution in original post

txnelson
Super User

Re: Using Column in table as ref line

The reality is that both the UWL and LWL charts are failing.  You just don't see the issue in the UWL chart.  It appears that when you specify an Add Ref Line to a chart when the value to chart is a missing value, ".", the code stops working from that point on for the chart.  In the case of the UWL chart, it has listed out all of the reference line you want to be displayed, before the code stops working when it runs into the missing value for the LWL reference line.  However, in the LWL chart, the UWL reference line is attemped before the LWL reference line, and the code stops working when it finds the missing value for the UWL reference line.  Several different ways of working around this are possing, below is one way to handle this

Names Default To Here( 1 );
dt = Current Data Table();

// Get all of the by values, since separate code will have to be added for each
Summarize( dt, byVals = by( :sex ) );

// Generate the Plot code
op = Overlay Plot(
	X( :height ),
	Y( :weight ),
	by( :sex ),
	SendToReport(
		Dispatch(
			{},
			"101",
			ScaleBox,
			{Label Row( Label Orientation( "Vertical" ) )}
		)
	)
);
	
For( i = 1, i <= N Items( byVals ), i++, 

	// Get the LCL and UCL values for this by group. UWL is only for F and LWL is for M 

	UCL = :UAL[(dt << get rows where( :sex == byVals[i] ))[1]];
	LCL = :LAL[(dt << get rows where( :sex == byVals[i] ))[1]];
	UWL = :UWarnL[(dt << get rows where( :sex == byVals[i] ))[1]];
	LWL = :LWarnL[(dt << get rows where( :sex == byVals[i] ))[1]];
show(byvals[i],ucl,lcl,uwl,lwl);	
	
	// Make sure the UCL and LCL values are displayed
	
	chartMin = Min( :weight[dt << get rows where( :sex == byVals[i])]);
	chartMax = Max( :weight[dt << get rows where( :sex == byVals[i])]);
	
	If(LCL < chartMin, chartMin = LCL );
	If(UCL > chartMax, chartMax = UCL );
	
	chartRange5% = (chartMax - ChartMin)/20;
	
	chartMin = chartMin - chartRange5%;
	chartMax = chartMax + chartRange5%;
	

	// Generate the code to produce the LCL and UCL reference lines
	Eval(
		Substitute(
				Expr(
					op << SendToByGroup(
						{:sex == __byVals__},
						Y Axis[1] << {{Min( __min__ ), Max( __max__ ),
						Add Ref Line( __UCL__, "Solid", "Medium Dark Red", "UAL", 1 ),
						Add Ref Line( __LCL__, "Solid", "Medium Dark Red", "LAL", 1 ),
						Add Ref Line( __WLVal__, "dotted", "Medium Dark Red", __WL__, 1 )
						}}
					)
				),
			Expr( __byVals__ ), byVals[i],
			Expr( __UCL__ ), UCL,
			Expr( __LCL__ ), LCL,
			Expr( __WLVal__ ), If(isMissing(UWL)==0,UWL,LWL),
			Expr( __WL__ ), If(isMissing(UWL)==0,"UWL","LWL"),
			Expr( __min__ ), chartMin,
			Expr( __max__ ), chartMax
		)
	);
);
Jim

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: Using Column in table as ref line

There is a Discussion Track that has covered this before.  See:

Define UCL/LCL in columns

Jim
Josee
Level II

Re: Using Column in table as ref line

Just what I need. This only works on JMP12 of course. Thank you. 

Josee
Level II

Re: Using Column in table as ref line

I went ahead and modified your script for what I need. It does work for what I need; however now that I added additional ref line I am having issues. Attached is a genereal example. Bigclass with additional columns are attached and the script I modified. I am trying to include an upper warn limit but the value will only be available for sex F. And for the M group there is a lower warn limit. When I run the script the UWL will appear for the first graph which is for group F but the LWL will not appear on 2nd graph group M. Any idea how to get around this?

Josee
Level II

Re: Using Column in table as ref line

Here is script as well

txnelson
Super User

Re: Using Column in table as ref line

The reality is that both the UWL and LWL charts are failing.  You just don't see the issue in the UWL chart.  It appears that when you specify an Add Ref Line to a chart when the value to chart is a missing value, ".", the code stops working from that point on for the chart.  In the case of the UWL chart, it has listed out all of the reference line you want to be displayed, before the code stops working when it runs into the missing value for the LWL reference line.  However, in the LWL chart, the UWL reference line is attemped before the LWL reference line, and the code stops working when it finds the missing value for the UWL reference line.  Several different ways of working around this are possing, below is one way to handle this

Names Default To Here( 1 );
dt = Current Data Table();

// Get all of the by values, since separate code will have to be added for each
Summarize( dt, byVals = by( :sex ) );

// Generate the Plot code
op = Overlay Plot(
	X( :height ),
	Y( :weight ),
	by( :sex ),
	SendToReport(
		Dispatch(
			{},
			"101",
			ScaleBox,
			{Label Row( Label Orientation( "Vertical" ) )}
		)
	)
);
	
For( i = 1, i <= N Items( byVals ), i++, 

	// Get the LCL and UCL values for this by group. UWL is only for F and LWL is for M 

	UCL = :UAL[(dt << get rows where( :sex == byVals[i] ))[1]];
	LCL = :LAL[(dt << get rows where( :sex == byVals[i] ))[1]];
	UWL = :UWarnL[(dt << get rows where( :sex == byVals[i] ))[1]];
	LWL = :LWarnL[(dt << get rows where( :sex == byVals[i] ))[1]];
show(byvals[i],ucl,lcl,uwl,lwl);	
	
	// Make sure the UCL and LCL values are displayed
	
	chartMin = Min( :weight[dt << get rows where( :sex == byVals[i])]);
	chartMax = Max( :weight[dt << get rows where( :sex == byVals[i])]);
	
	If(LCL < chartMin, chartMin = LCL );
	If(UCL > chartMax, chartMax = UCL );
	
	chartRange5% = (chartMax - ChartMin)/20;
	
	chartMin = chartMin - chartRange5%;
	chartMax = chartMax + chartRange5%;
	

	// Generate the code to produce the LCL and UCL reference lines
	Eval(
		Substitute(
				Expr(
					op << SendToByGroup(
						{:sex == __byVals__},
						Y Axis[1] << {{Min( __min__ ), Max( __max__ ),
						Add Ref Line( __UCL__, "Solid", "Medium Dark Red", "UAL", 1 ),
						Add Ref Line( __LCL__, "Solid", "Medium Dark Red", "LAL", 1 ),
						Add Ref Line( __WLVal__, "dotted", "Medium Dark Red", __WL__, 1 )
						}}
					)
				),
			Expr( __byVals__ ), byVals[i],
			Expr( __UCL__ ), UCL,
			Expr( __LCL__ ), LCL,
			Expr( __WLVal__ ), If(isMissing(UWL)==0,UWL,LWL),
			Expr( __WL__ ), If(isMissing(UWL)==0,"UWL","LWL"),
			Expr( __min__ ), chartMin,
			Expr( __max__ ), chartMax
		)
	);
);
Jim
dirty1026
Level I

Re: Using Column in table as ref line

Quick questions. How if I have several By groups with different kinds of limit instead of just by (:sex)?

Summarize( dt, byVals = by( :sex, :age ) );

UCL = :UAL[(dt << get rows where( :sex, :age == byVals[i] ))[1]];
txnelson
Super User

Re: Using Column in table as ref line

Then you will have to set up your jsl to handle the various By groups and retrieve the different Limits based upon which By group is appropriate.
Jim
ileshem
Level III

Re: Using Column in table as ref line

Hi, I was using that on an overlay plot and it works like a charm.

I now want to use that on a oneway plot but is doesn't seems to work. is there any other way to use that on an oneway plot?