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

Can columns be plotted in graph builder be separated by PAGE using a column name categories?

The script below plots a few columns (multiple parameters on Y axis) with column names starting with P in Graph Builder. I want to simultaneously plot a few other columns which with column names starting with N in the next PAGE (command commented in my script below).

In the next PAGE I would like to plot a few other columns with column names starting with, say  V and so on.

The column category information can come predefined either in a separate data table or in any other form, perhaps a list (I am flexible on that). The question is whether this is doable via JSL and if so how?

Names Default To Here (1);
clear log ();
dt = open( "$SAMPLE_DATA\semiconductor capability.jmp" ); 
dt << Ungroup Columns();
Graph Builder(Size( 1469, 718 ),
	Variables(X( :lot_id ), Y( :PLG2 ), Y( :PNP4 ), Y( :PNP3 ), Y( :PNP2 ), Y( :PNP1 )),
	//Page(:ColumCategory)
	Elements( Position( 1, 1 ), Box Plot( X, Y, Legend( 14 ) ) ),
	Elements( Position( 1, 2 ), Box Plot( X, Y, Legend( 12 ) ) ),
	Elements( Position( 1, 3 ), Box Plot( X, Y, Legend( 11 ) ) ),
	Elements( Position( 1, 4 ), Box Plot( X, Y, Legend( 9 ) ) ),
	Elements( Position( 1, 5 ), Box Plot( X, Y, Legend( 10 ) ) ),
);

 

 

 

When it's too good to be true, it's neither
19 REPLIES 19
Neo
Neo
Level VI

Re: Can columns be plotted in graph builder be separated by PAGE using a column name categories?

@txnelson @hogi . Thanks for your suggestions. I am back on this topic after a short break.

@jthi Running this part of your script in my JMP 16.2

Names Default To Here(1);
create_graph = Function({dt, ycollist}, {Default Local},
	vlb = V List Box(
		gb = dt << Graph Builder(Variables(X(:lot_id)))
	);
	For Each({colname, idx}, ycollist,
		gb << Add Variable({Eval(colname), Role("Y")});
		gb << Add Element(1, idx, {Type("Box Plot"), X, Y}); // define boxplots
		gb << Remove Element(1, idx, 1); // remove points
	);	
	return(vlb);
);
my_groups = {{"PNP1", "PNP2", "PNP3"}, {"NPN3", "NPN2", "NPN1", "NPN4"}};
dt = Open("$SAMPLE_DATA\semiconductor capability.jmp");
// could also just create journal and add new_vlb to that
nw = New Window("Collector",
	vlb = V List Box()
);
For Each({my_group}, my_groups,
	new_vlb = create_graph(dt, my_group);
	vlb << Append(new_vlb);
);

gives

Neo_0-1704275938100.png

i.e. 

{"PNP1", "PNP2", "PNP3"} 

and 

{"NPN3", "NPN2", "NPN1", "NPN4"}

are not plotted on the y-axis as mentioned in my first post (i.e. one above the other with spec limit ref lines visible) and on two separate charts.

As mentioned above, my parameters to plot are grouped as in the following separate table 

Names Default To Here( 1 );
dtg = New Table( "Parameter Groups",
	Add Rows( 11 ),
	New Column( "Parameter", Character, Nominal, 
	Set Values( {"PNP1", "PNP2", "NPN2", "NPN3", "INV2", "NPN1", "PNP3", "NPN4", "INV3", "PNP6", "INV4"} ) ),
	New Column( "Group", Character, Nominal, Set Values( {"DC", "DC", "AC","AC","RF","AC","DC","AC", "RF", "DC", "RF"} ) )
);

I would like the parameters in each chart to be grouped by the entry in the Group column of the above table.

e.g.  the Top plot has a tile of DC with "PNP1", "PNP2", "PNP3" and "PNP6" plotted on the y-axis and below it the next chart with title AC with "NPN2", "NPN3", "NPN1" and "NPN4" plotted and finally the third chart at the bottom with title "RF" with "INV2" and "INV4" plotted on the y-axis.

Could I please get some help with the associative array approach to proceed? This way I can get the unique Groups, but how to get the associated Parameters (use Get Rows Where ())?

gg  = Associative Array (dt:Group);
gg << get keys;

 (@jthi, I prefer your "collector" window option in addition to the journal as it gives we more flexibility depending on what I want to look at)

When it's too good to be true, it's neither
txnelson
Super User

Re: Can columns be plotted in graph builder be separated by PAGE using a column name categories?

Using JMP 16, I was able to recreate the issue you are seeing.  I failed in using the Add Variables, etc. to get the results you want.  However, by using a technique where the Graph Builder JSL is created in a string variable and then executed, I was able to get the box plots

txnelson_0-1704289573117.png

Names Default To Here( 1 );

create_graph = Function( {dt, ycollist},
	{Default Local},
	theExpr =
	"vlb = V List Box(
		gb = dt << Graph Builder(Size( 1469, 718 ),Variables(X(:lot_id)";
	
	For Each( {colname, idx}, ycollist,
		theExpr = theExpr || ",Y(:\!"" || colname || "\!"n)"
	);
	theExpr = theExpr || ")";
	For Each( {colname, idx}, ycollist,
		theExpr = theExpr || ",Elements( Position( 1," || Char( idx ) ||
		" ), Box Plot( X, Y) ) "
	);
	theExpr = theExpr || ");";
	Eval( Parse( theExpr ) );
	Return( vlb );
);
my_groups = {{"PNP1", "PNP2", "PNP3"}, {"NPN3", "NPN2", "NPN1", "NPN4"}};
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );
// could also just create journal and add new_vlb to that
nw = New Window( "Collector", vlb = V List Box() );
For Each( {my_group}, my_groups,
	new_vlb = create_graph( dt, my_group );
	vlb << Append( new_vlb );
);
Jim
Neo
Neo
Level VI

Re: Can columns be plotted in graph builder be separated by PAGE using a column name categories?

@txnelson This works in 16.2 (JMP complains of syntax errors but still plots the chart).

How to break out of the create_graph function if ycollist is empty?

Also, if I have a another list 

paraGroupList = {"DC", "AC"};

How do I assign DC as chart title (currently PNP1 & 2 more vs. lot_id) when plotting (top chart)

{"PNP1", "PNP2", "PNP3"}

and AC as the chart title (currently NPN3 & 3 more vs. lot_id) for when plotting (bottom chart)?

{"NPN3", "NPN2", "NPN1", "NPN4"}

 

When it's too good to be true, it's neither
txnelson
Super User

Re: Can columns be plotted in graph builder be separated by PAGE using a column name categories?

Run the graph.

Click on the title and change it.

Then go to the red triangle and select to save the script.

Look in the script and you will see the JSL and how it changed the title.

Adopt it into your script.

 

I strongly suggest that you take the time to read the Scripting Guide.  It will speed up your learning of JSL

Jim
Neo
Neo
Level VI

Re: Can columns be plotted in graph builder be separated by PAGE using a column name categories?

@txnelson  Thanks, I figured out how to do the chart title. 

How to break out of the create_graph function if ycollist is empty?

When it's too good to be true, it's neither
txnelson
Super User

Re: Can columns be plotted in graph builder be separated by PAGE using a column name categories?

use the Length() function to check to see if the list has any entries, and then bypass the code;

Jim
Neo
Neo
Level VI

Re: Can columns be plotted in graph builder be separated by PAGE using a column name categories?

@txnelson Thanks.  It seems I cannot use break () within my plotting function if it is used inside a for loop. I will see what options I have.

When it's too good to be true, it's neither
txnelson
Super User

Re: Can columns be plotted in graph builder be separated by PAGE using a column name categories?

Just make the evaluation needed, and if it is not met, then bypass the code.  See Below:

Names Default To Here( 1 );

create_graph = Function( {dt, ycollist},
	{Default Local},
	theExpr =
	"vlb = V List Box(
		gb = dt << Graph Builder(Size( 1469, 718 ),Variables(X(:lot_id)";
	
	For Each( {colname, idx}, ycollist, 
	
		If( Length( colname ) != 0, 
	
			theExpr = theExpr || ",Y(:\!"" || colname || "\!"n)"
		);
		theExpr = theExpr || ")";
		For Each( {colname, idx}, ycollist,
			theExpr = theExpr || ",Elements( Position( 1," || Char( idx ) ||
			" ), Box Plot( X, Y) ) "
		);
		theExpr = theExpr || ");";
		Eval( Parse( theExpr ) );
	
	);
	
	Return( vlb );
);
my_groups = {{"PNP1", "PNP2", "PNP3"}, {"NPN3", "NPN2", "NPN1", "NPN4"}};
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );
// could also just create journal and add new_vlb to that
nw = New Window( "Collector", vlb = V List Box() );
For Each( {my_group}, my_groups,
	new_vlb = create_graph( dt, my_group );
	vlb << Append( new_vlb );
);
Jim
Neo
Neo
Level VI

Re: Can columns be plotted in graph builder be separated by PAGE using a column name categories?

@txnelson Thanks. Running the script gives me errors (on JMP 16.2) which I am unable to get rid of.

Neo_0-1704379900966.png

 

When it's too good to be true, it's neither
txnelson
Super User

Re: Can columns be plotted in graph builder be separated by PAGE using a column name categories?

Sorry, I rushed to my previous answer.  The below JSL will bypass the creation of the graph if the my_group is empty

Names Default To Here( 1 );

create_graph = Function( {dt, ycollist},
	{Default Local}, 
	
	theExpr =
	"vlb = V List Box(
		gb = dt << Graph Builder(Size( 1469, 718 ),Variables(X(:lot_id)";
	
	For Each( {colname, idx}, ycollist, 
	
		theExpr = theExpr || ",Y(:\!"" || colname || "\!"n)"
	);
	theExpr = theExpr || ")";
	For Each( {colname, idx}, ycollist, 
	
		theExpr = theExpr || ",Elements( Position( 1," || Char( idx ) ||
		" ), Box Plot( X, Y) ) "
	);
	theExpr = theExpr || ");";
	
	Eval( Parse( theExpr ) );
	
	Return( vlb );
);
my_groups = {{"PNP1", "PNP2", "PNP3"}, {"NPN3", "NPN2", "NPN1", "NPN4"}};
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );
// could also just create journal and add new_vlb to that
nw = New Window( "Collector", vlb = V List Box() );
For Each( {my_group}, my_groups,
	If( Length( my_group ) != 0,
		new_vlb = create_graph( dt, my_group );
		vlb << Append( new_vlb );
		vlb = V List Box();
	)
);
Jim