cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar

How to update Y-axis reference lines label in numeric value using JSL script (Automate plots with USL LSL label)

As title stated, How to update Y-axis reference lines label in numeric value using JSL script (Automate plots with USL LSL label)?

I am currently using JSL script to generate a series of plots from a set of data table, in order to show the distribution plots with USL/LSL limits in one click. And those limits showed in the plots are based on the Manage Limits table (I updated values). But one more step to improve is to show those USL/LSL label in actual numeric values based on the Manage Limits table, I coudn't find the relevant JSL commands to automate it except I have to update the labels manually one by one.. anyone know how to show some example? Thanks in advance.

 

JSL_labelling.png

 

	For( i = 1, i <= 100, i++,
		xCol = Column(dt, i);
		
		if ( Mod( i-8, 5 ) == 0,
		rowBox = hlistbox();
		win << Append( rowBox )			
		);
		rowBox << Append(
		//New Window( "training - Fit Y by X by Serial",
			//dt << Fit Group(
				Graph Builder(
					Size( 350, 350 ),
					Fit to Window("off"),
					Show Control Panel( 0 ),
					Show Title ( 1 ),
					Show Subtitle ( 0 ), 
					Show Legend( 1 ),
					Show Header ( 0 ),
					Show Footer ( 0 ),
					//Update Variable to Column Name
					Variables(X( :TEMP ),Y( xCol ),Overlay( :Unit )),
					Elements( Smoother( X, Y, Legend( 8 ) ), Points( X, Y, Legend( 9 ) ) ),
					SendToReport(
						Dispatch(
							{}, "Graph Builder", 
							OutlineBox, {Set Title( "" ), Image Export Display(Normal)},
						),
						Dispatch(
							{}, "Graph Builder", 
							FrameBox,{Transparency(0.8), Left( 0 ), Right( 0 ), Top( 1 ), Bottom( 1 )},
						)

//To update labels USL/LSL limits in numeric value
					)
				)
8 REPLIES 8
jthi
Super User

Re: How to update Y-axis reference lines label in numeric value using JSL script (Automate plots with USL LSL label)

This might give some ideas https://community.jmp.com/t5/Discussions/Change-Line-Color-and-Line-Style-in-all-platforms/m-p/81979...

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

ml = dt << Manage Limits(
	Process Variables(dt << Get Column Group("Processes")),
);
ml << Show Limits All;
ml << Save to Column Properties;
ml << Close Window;

dt << Distribution(
	Stack(1),
	Continuous Distribution(
		Column(:NPN1),
		Horizontal Layout(1),
		Vertical(0),
		Process Capability(Use Column Property Specs)
	)
);

// "Tool script" starts from here
// Names Default To Here(1);
abs = Current Report() << XPath("//AxisBox");
names = {"A", "B", "C", "D"};
idx = 0;
For Each({ab}, abs,
	s = ab << get script;
	For Each({cur_s}, s,
		If(Head Name(cur_s) == "Add Ref Line",
			l = Substitute(Name Expr(cur_s), Expr(Add Ref Line()), Expr(List()));
			If(Contains(l, "LSL") | Contains(l, "Target") | Contains(l, "USL"),
				// this isn't documented
				idx++;
				Eval(EvalExpr(
					ab << Update Ref Line(1, Expr(idx), "Solid", "Orange", names[idx], 3);
				));
			);
		);
	);
);

If it is just one specific platform and one axis, this can be most likely simplified

-Jarmo

Re: How to update Y-axis reference lines label in numeric value using JSL script (Automate plots with USL LSL label)

Thanks Jarmo. This is good in showing the plots in process capability way, it also showing the USL LSL instead of numeric value. I have the manage limit table updated already, just wish to have one more step to show those limits in numeric value in the plot via JSL script.

jthi
Super User

Re: How to update Y-axis reference lines label in numeric value using JSL script (Automate plots with USL LSL label)

I assume you didn't understand the script I did provide you as it does show how to rename the spec limits in a plot. This will use the values instead of LSL, USL and Target text

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

ml = dt << Manage Limits(
	Process Variables(dt << Get Column Group("Processes")),
);
ml << Show Limits All;
ml << Save to Column Properties;
ml << Close Window;

gb = dt << Graph Builder(
	Size(528, 448),
	Show Control Panel(0),
	Variables(X(:SITE), Y(:NPN1)),
	Elements(Points(X, Y, Legend(3)))
);

abs = Report(gb) << XPath("//AxisBox");
idx = 0;
For Each({ab}, abs,
	s = ab << get script;
	For Each({cur_s}, s,
		If(Head Name(cur_s) == "Add Ref Line",
			l = Substitute(Name Expr(cur_s), Expr(Add Ref Line()), Expr(List()));
			If(Contains(l, "LSL") | Contains(l, "Target") | Contains(l, "USL"),
				idx++;
				Eval(EvalExpr(
					ab << Update Ref Line(1, Expr(idx), "Solid", "Blue", Char(l[1]), 1);
				));
			);
		);
	);
);

jthi_0-1735063101776.png

Most likely it will be better to not use spec limit column properties with Show Limits enabled and just add limits as reference lines based on the column properties with your own name

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

gb = dt << Graph Builder(
	Size(528, 448),
	Show Control Panel(0),
	Variables(X(:SITE), Y(:NPN1)),
	Elements(Points(X, Y, Legend(3)))
);

specs = Column(dt, "NPN1") << get property("Spec Limits");
Report(gb)[AxisBox(2)] << Add Ref Line(
	specs["LSL"], "Solid", "Blue", Char(specs["LSL"]), 1
);

Report(gb)[AxisBox(2)] << Add Ref Line(
	specs["USL"], "Solid", "Blue", Char(specs["USL"]), 1
);

 

-Jarmo
txnelson
Super User

Re: How to update Y-axis reference lines label in numeric value using JSL script (Automate plots with USL LSL label)

Here is a simple script that sets the Spec Limits for a column and then runs the Graph Builder, which automatically displays the Spec Limits

txnelson_0-1734764235477.png

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

htUSL = 66;
htLSL = 55;

Eval(
	Eval Expr(
		dt:height << set property(
			"spec limits",
			{LSL( Expr( htLSL ) ), USL( Expr( htUSL ) ), Show Limits( 1 )}
		)
	)
);

dt << Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);

Jim

Re: How to update Y-axis reference lines label in numeric value using JSL script (Automate plots with USL LSL label)

Thanks nelson, the code is similar to my code and it also can't show the reference lines of USL LSL in numeric value.

I tried use the Num(htUSL) to change it in numeric value but it generate the plot without reference lines at all, which we will have to use Expr (htUSL) to show the lines. It seems there is no other option to show those limits in numeric value via JSL script, except in manual way..

 

htUSL = 66;
htLSL = 55;

Eval(
	Eval Expr(
		dt:height << set property(
			"spec limits",
			{LSL( Expr( htLSL ) ), USL( Expr( htUSL ) ), Show Limits( 1 )},
			{LSL( Num( htLSL ) ), USL( Num( htUSL ) ), Show Limits( 1 )}, //Not working
		)
	)
);
txnelson
Super User

Re: How to update Y-axis reference lines label in numeric value using JSL script (Automate plots with USL LSL label)

Why are you using 2 lists in the Set Property("Spec Limits") function?  Only one set of limits are permitted for Spec Limits.  Additionally, the Eval( EvalExpr() function looks for Expr() in the enclosed function, and expands the value of each Expr() and then the Eval() function can properly evaluate it.  In your second Spec Limits specification, you replaced the Expr() with Num().  because it is inside of a JMP List, no evaluation of it or the htLSL and the htUSL will be evaluated, thus what is passed to JSL will be unknown to JMP.

If you are attempting to run more than one column, each column will have to have their spec limits separately. 

 

Have you run my example....without change?  If so, does it produce a graph with USL and LSL reference lines?

Jim

Re: How to update Y-axis reference lines label in numeric value using JSL script (Automate plots with USL LSL label)

Hi Jim, it is about changing the reference lines in numeric value instead of "USL" text.

Your code example is able to show a graph with USL, LSL reference lines without any change, I just want to show that USL/LSL into numeric value (reference from manage limit table).

 

Attached snapshot to show my desire to change the USL,LSL in numeric value (see right side), but wish it can be done in JSL script for automation. Thanks.

Label_in_numeric.png

 

txnelson
Super User

Re: How to update Y-axis reference lines label in numeric value using JSL script (Automate plots with USL LSL label)

Here is an example where an existing limits table is used to create the reference lines.  There are 2 different examples using 2 different methods

txnelson_0-1735054703824.png

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

// open a limits table created from Manage Limits
dtLimit = New Table( "Limits",
	Add Rows( 2 ),
	New Column( "Variable", Character, "Nominal", Set Values( {"height", "weight"} ) ),
	New Column( "LSL", Set Values( [55, 65] ) ),
	New Column( "USL", Set Values( [66, 170] ) ),
	New Column( "Target", Set Selected, Set Values( [., .] ) )
);

// One way to set the reference lines
colNames = dt << get column names( string, continuous );

// Create the graphs
For Each( {col}, colNames,
	gb = dt << Graph Builder(
		Size( 534, 456 ),
		Show Control Panel( 0 ),
		Variables( X( :age ), Y( As Column( col ) ) ),
		Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
	);

// Set the ref lines
	// Get the row in the limits table that has the limits for the current column
	theRow = (dtLimit << get rows where( dtLimit:Variable == col ))[1];
	Report( gb )[AxisBox( 2 )] << add ref line(
		dtLimit:LSL[theRow],
		"Solid",
		"Blue",
		Char( dtLimit:LSL[theRow] ),
		1
	);
	Report( gb )[AxisBox( 2 )] << add ref line(
		dtLimit:USL[theRow],
		"Solid",
		"Blue",
		Char( dtLimit:USL[theRow] ),
		1
	);
);

// Second way to set the reference lines using Spec Limits column property
// the default when using the Spec Limits is for graph builder to insure
// the spec limits are displayed on the graph.  This example with use the
// spec limits, and then change the label to a numeric 
colNames = dt << get column names( string, continuous );

ml = dt << Manage Limits( Process Variables( Eval( colNames ) ) );
ml << load from limits table( dtLimit );
ml << Show Limits All;
ml << Save to Column Properties;
ml << Close Window;

// Create the graphs
For Each( {col}, colNames,
	gb = dt << Graph Builder(
		Size( 534, 456 ),
		Show Control Panel( 0 ),
		Variables( X( :age ), Y( As Column( col ) ) ),
		Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
	);

// Set the ref lines
	// Get the limits from the spec limits for the current column
	// and change the label
	specs = Column( dt, col ) << get property( spec limits );
	Report( gb )[AxisBox( 2 )] << add ref line( specs["LSL"], "Solid", "Blue", Char( specs["LSL"] ), 1 );
	Report( gb )[AxisBox( 2 )] << add ref line( specs["USL"], "Solid", "Blue", Char( specs["USL"] ), 1 );
);
Jim