Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
EMC2
Level I

Graph builder

The auto generated script from Graph builder has three variables (X, Y1,Y2). So i am using this auto generated script for plotting same grpah for different set of data. This is working. But whenever Y2 variable is not there in the new set of data, script is giving error. This is expected. But i would like to modify the script in such a way that it generate graph for the available variable and just ignore Y2 variable if its not availble in the given data set without giving error. Please help me to get this. Thanks!

3 REPLIES 3
Highlighted
txnelson
Super User

Re: Graph builder

Here is one way to handle the issue

Names Default To Here( 1 );

dt = Current Data Table();

If( Try( dt:Sex << get name, "" ) != "",
	Graph Builder(
		Variables( X( :weight ), Y( :height ), Overlay( :sex ) ),
		Elements( Points( X, Y, Legend( 8 ) ), Smoother( X, Y, Legend( 9 ) ) )
	),
	Graph Builder(
		Variables( X( :weight ), Y( :height ) ),
		Elements( Points( X, Y, Legend( 10 ) ), Smoother( X, Y, Legend( 11 ) ) )
	)
);

You need to take the time to read the scripting documentation!

     Help==>Books==>Scripting Guide

Jim
Highlighted
EMC2
Level I

Re: Graph builder

Thanks! Sure i will read the guideline. However your suggestion of using if loop is too difficult for my case as i have too many Y variables and also too many plots to be done for the given data set. Do we have any function which can handle my issue in lean way. Thanks!
Highlighted
txnelson
Super User

Re: Graph builder

My last response was intended not to be a final solution, but to give you a hint as to one way to solve the problem.  I strongly suggest you read the Scripting Guide, which will show you the structures and elements of JSL, which will allow you to take methods such as the one I suggested, and expand on it to give you your final solution.

     Help==>Books==>Scripting Guide

 

Below is an expansion on my previous methodology illustrating some of the elements of JSL that can be put together to provide you with your solution

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

colNamesList = dt << get column names( continuous );

// Reduce the list down to only the columns that have a "1" as the last character
For( i = N Items( colNamesList ), i >= 1, i--,
	If( Substr( Char( colNamesList[i] ), Length( Char( colNamesList[i] ) ), 1 ) != "1",
		colNamesList = Remove( colNamesList, i, 1 )
	)
);

// Create a Display Window to hold all of the graphs
nw = New Window( "The Graphs", vlb = V List Box() );

// Loop through the targeted graphs, adding a second Y coloumn if a column with the
// same name as the graphing column exists, but has a "4" as its ending
For( i = 1, i <= 10, i++, //N Items( colNamesList ), i++,
	the4Version = (Substr( Char( colNamesList[i] ), 1, Length( Char( colNamesList[i] ) ) - 1 ) || "4");
	If( Try( Column( dt, the4Version, "" ) << get name ) == "",
		gb = Graph Builder(
			invisible,
			Size( 534, 448 ),
			Show Control Panel( 0 ),
			Variables( X( :lot_id ), Y( colNamesList[i] ) ),
			Elements( Box Plot( X, Y, Legend( 4 ) ) )
		),
		gb = Graph Builder(
			invisible,
			Size( 534, 448 ),
			Show Control Panel( 0 ),
			Variables( X( :lot_id ), Y( colNamesList[i] ), Y( As Column( the4Version ), Position( 1 ) ) ),
			Elements( Box Plot( X, Y( 1 ), Y( 2 ), Legend( 4 ) ) )
		)
	);
	vlb << append( Report( gb ) );
	gb << close window;
);
Jim
Article Labels

    There are no labels assigned to this post.