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

Dynamically adding distribution plots to a table

I have a table with roughly ~180 columns of data. 

 

I'd like to dynamically add a distribution plot (to the table) for each column via a for loop in JSL (with a local data filter specific to each column). 

 

Is this possible? What happens in my attempts is all the attached plots are the last value of the for loop. Probably something simple I'm missing.

 

thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Dynamically adding distribution plots to a table

Your script does not completely flesh out the required JSL to allow for the table scripts to work.  The reference of myTests needs to be parsed into the exact column name in order for the table script to be able to run properly.  The JSL below forces the expansion of the code before saving it to the data table.  I also added a Local Filter and I also changed the code to make the script name the column name

Names Default To Here( 1 );
Clear Log();
Clear Globals();

dt = 
// Open Data Table: Blood Pressure.jmp
// → Data Table( "Blood Pressure" )
Open( "$SAMPLE_DATA/Blood Pressure.jmp" );

myTests = dt << get column names( string, numeric );



For( i = 1, i <= N Items( myTests ), i++,
	Eval(
		Eval Expr(
			dt << Add Properties to Table(
				{New Script(
					expr(myTests[i]),
					Distribution(
						Stack( 1 ),
						Continuous Distribution( Column( Expr( myTests[i] ) ) ),
						Horizontal Layout( 1 ),
						Vertical( 0 ),
						Outlier Box Plot( 0 ),
						Process Capability( Use Column Property Specs ),
						Local Data Filter( Add Filter( columns( Expr( myTests[i] )) ) )
					)
				)}
			)
		)
	)
);

 

Jim

View solution in original post

7 REPLIES 7
mmarchandTSI
Level V

Re: Dynamically adding distribution plots to a table

It's possible.  If you can attach a sanitized version of your script, It'll be easier and quicker to help.

matador951
Level II

Re: Dynamically adding distribution plots to a table

Here's a shortened version:

 

 
Clear Log();
Clear Globals();
dt = current data table ();

myTests = {:Name ("Cont_VDD"), :Name ("Cont_OUTP")};



for (i=1, i<= 2, i++,
	
	dt << Add Properties to Table(
	{New Script(
		"Distribution",
		Distribution(
			Stack( 1 ),
			Continuous Distribution(
				Column( myTests[i] ) ),
				Horizontal Layout( 1 ),
				Vertical( 0 ),
				Outlier Box Plot( 0 ),
				Process Capability( Use Column Property Specs )
			)
		)
	});
);
 

 

txnelson
Super User

Re: Dynamically adding distribution plots to a table

Your script does not completely flesh out the required JSL to allow for the table scripts to work.  The reference of myTests needs to be parsed into the exact column name in order for the table script to be able to run properly.  The JSL below forces the expansion of the code before saving it to the data table.  I also added a Local Filter and I also changed the code to make the script name the column name

Names Default To Here( 1 );
Clear Log();
Clear Globals();

dt = 
// Open Data Table: Blood Pressure.jmp
// → Data Table( "Blood Pressure" )
Open( "$SAMPLE_DATA/Blood Pressure.jmp" );

myTests = dt << get column names( string, numeric );



For( i = 1, i <= N Items( myTests ), i++,
	Eval(
		Eval Expr(
			dt << Add Properties to Table(
				{New Script(
					expr(myTests[i]),
					Distribution(
						Stack( 1 ),
						Continuous Distribution( Column( Expr( myTests[i] ) ) ),
						Horizontal Layout( 1 ),
						Vertical( 0 ),
						Outlier Box Plot( 0 ),
						Process Capability( Use Column Property Specs ),
						Local Data Filter( Add Filter( columns( Expr( myTests[i] )) ) )
					)
				)}
			)
		)
	)
);

 

Jim
matador951
Level II

Re: Dynamically adding distribution plots to a table

many thanks!!!  I've taught myself JSL... and have hit a few roadblocks along the way... the use of Eval is now clear to me,... thanks again!

 

--Matt

txnelson
Super User

Re: Dynamically adding distribution plots to a table

Additionally, if it is just simple Histograms you are looking for, starting with JMP 15, a Histogram can be displayed above each column just by selecting the Histogram Icon in the data table

txnelson_0-1705595865814.png

 

Jim
txnelson
Super User

Re: Dynamically adding distribution plots to a table

I am not sure what exactly you are looking for.  Here is a simple script that creates all of the distributions with the local data filter.

Names Default To Here( 1 );

dt = 
// Open Data Table: Blood Pressure.jmp
// → Data Table( "Blood Pressure" )
Open( "$SAMPLE_DATA/Blood Pressure.jmp" );

ColNames = dt << get column names( string, numeric );

nw = New Window( "Distributions",
	H List Box(

		For Each( {Col}, ColNames,
			Eval(
				Eval Expr(
					Distribution(
						Continuous Distribution( Column( Eval( col ) ) ),
						Local Data Filter( Add Filter( columns( Eval( col )) ) )
					)
				)
			)
		)
	)
);

	

txnelson_0-1705532200758.png

 

Jim

Re: Dynamically adding distribution plots to a table

If you use a global variable in the launch script for Distribution, then it will use the current value stored in the variable. You need to convert it to a literal value for the launch script.