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
LBrian
Level III

Input multiple spec to contour plot using JSL

Hello everyone.

 

I am studying JSL to making contour plot easily.

But I have a problem about 'specify contours()' function.

When I run this code, the spec is fixed one.

 

Could you please give me help?

 

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

win = New Window( "Select Item(s)",
		<<Modal,
		Text Box( "Item List" ),
		H List Box(
			allcols = Col List Box( dt, all ),
			Lineup Box(
				2,
				V List Box(
					bbAdd = Button Box( "Add", xcols << append( allcols << get selected ) ),
					bbRemove = Button Box( "Remove", xcols << remove selected )
				),
				xcols = Col List Box( "Numeric", <<Modeling Type( {"Continuous"} ), min items( 1 ) )
			),
			V List Box(
				bbOK = Button Box( "OK", 
				xvar = (xcols << Get Items);
				str = "";
			 
			
				If( NItems( xvar ) == 0,
					ErrWin = New Window( "Sorry",
						<<modal,
						Text Box( "\!N Please add item at least one \!N\!N" ) 
					)	
				);
				bbCancel = Button Box( "Cancel", Throw() )
			)
		)
	)
	);

dt << Contour Plot(
	X( :height, :weight ),
	Y( Eval(xvar) ),
	Legend( 2 ),
	Show Contours( 1 ),
	Show Data Points( 0 ),
	Fill Areas( 1 ),
	Label Contours( 0 ),
	Color Theme( "Blue White Red" ),    Specify Contours( Min(Column( dt,Eval(xvar))[3]), Max( Column( dt, Eval( xvar))[4]), N( 10 ) ),
	SendToReport(
		Dispatch(
			{},
			"1", 
			
		),
		Dispatch(
			{},
			"2", 
	
		),
		Dispatch( {}, "meow", TextEditBox, {Rotate Text( "Horizontal" )} ),
		Dispatch(
			{},
			"Contour Plot Graph",
			FrameBox,
			{Frame Size( 700, 700 ), Marker Size( 2 ), Marker Drawing Mode( "Normal" ),
			Marker Selection Mode( "Unselected Faded" )
				
			}
		),
		Dispatch( {}, "", AxisBox( 2 ), {Add Axis Label( "-meow-" )} ),
		Dispatch( {}, "Contour Legend", FrameBox, {Frame Size( 101, 87 )} )
	)
);

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp
Level X

Re: Input multiple spec to contour plot using JSL

So I think I mis-understood what you wanted. The Contour Plot platform does allow multiple Ys, and if you wanted, say, at least two Ys, you can (more or less) return to your original code (see below). But in this case, the same set of contour values will be applied to every Y the user defines.

 

If you want to allow each Y to have its own contour values I assume you would need to update your UI. You could then launch the platform separately for each Y, and put all the reports in a single window. This is probably not a good first project if you are new to JSL though.

 

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

win = New Window( "Select Item(s)",
		<<Modal,
		Text Box( "Item List" ),
		H List Box(
			allcols = Col List Box( dt, all ),
			Lineup Box(
				2,
				V List Box(
					bbAdd = Button Box( "Add", xcols << append( allcols << get selected ) ),
					bbRemove = Button Box( "Remove", xcols << remove selected )
				),
				// Use 'max items()' to only allow one Y to be selected
				xcols = Col List Box( "Numeric", <<Modeling Type( {"Continuous"} ), min items( 2 ))
			),
			V List Box(
				bbOK = Button Box( "OK",
				// 'xvar' is a list
				xvar = (xcols << Get Items);
				str = "";
			 
			
				If( NItems( xvar ) == 0,
					ErrWin = New Window( "Sorry",
						<<modal,
						Text Box( "\!N Please add item at least one \!N\!N" ) 
					)	
				);
				bbCancel = Button Box( "Cancel", Throw() )
			)
		)
	)
	);

dt << Contour Plot(
	X( :height, :weight ),
	Y( Eval(xvar) ),
	Legend( 2 ),
	Show Contours( 1 ),
	Show Data Points( 0 ),
	Fill Areas( 1 ),
	Label Contours( 0 ),
	Color Theme( "Blue White Red" ),
	// You don't need 'Eval(xvar)' here. This usses some contour values from the second variable in 'xvar' for all variables in 'xvar'
	Specify Contours( Min(Column( dt, xvar[2])[5]), Max( Column( dt, xvar[2])[2]), N( 4 ) ),
);

   

View solution in original post

4 REPLIES 4
ian_jmp
Level X

Re: Input multiple spec to contour plot using JSL

Looks like you need to spend a little time with 'Help > Books > Scripting Guide', or one of many other resources that will help you get more familiar with JSL.

It seems as if you want to allow the user to select one (and only one) variable for the 'Y' role in the Contour Plot platform. If that's so, please look at these slight changes to your code above:

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

win = New Window( "Select Item(s)",
		<<Modal,
		Text Box( "Item List" ),
		H List Box(
			allcols = Col List Box( dt, all ),
			Lineup Box(
				2,
				V List Box(
					bbAdd = Button Box( "Add", xcols << append( allcols << get selected ) ),
					bbRemove = Button Box( "Remove", xcols << remove selected )
				),
				// Use 'max items()' to only allow one Y to be selected
				xcols = Col List Box( "Numeric", <<Modeling Type( {"Continuous"} ), min items( 1 ), max items(1) )
			),
			V List Box(
				bbOK = Button Box( "OK",
				// 'xvar' is a list (containing only one item) 
				xvar = (xcols << Get Items);
				// Put this first item into a variable (with the same name)
				xvar = xvar[1];
				str = "";
			 
			
				If( NItems( xvar ) == 0,
					ErrWin = New Window( "Sorry",
						<<modal,
						Text Box( "\!N Please add item at least one \!N\!N" ) 
					)	
				);
				bbCancel = Button Box( "Cancel", Throw() )
			)
		)
	)
	);

dt << Contour Plot(
	X( :height, :weight ),
	Y( Eval(xvar) ),
	Legend( 2 ),
	Show Contours( 1 ),
	Show Data Points( 0 ),
	Fill Areas( 1 ),
	Label Contours( 0 ),
	Color Theme( "Blue White Red" ),
	// You don't need 'Eval(xvar)' here . . .
	Specify Contours( Min(Column( dt, xvar)[3]), Max( Column( dt, xvar)[4]), N( 2 ) ),
);
LBrian
Level III

Re: Input multiple spec to contour plot using JSL

Above of all,

Thank you for your reply.

 

I knew that can be worked but I want to select multiple items.

I will study JSL more and try to change code form for convenience.

 

Thank you again.

ian_jmp
Level X

Re: Input multiple spec to contour plot using JSL

So I think I mis-understood what you wanted. The Contour Plot platform does allow multiple Ys, and if you wanted, say, at least two Ys, you can (more or less) return to your original code (see below). But in this case, the same set of contour values will be applied to every Y the user defines.

 

If you want to allow each Y to have its own contour values I assume you would need to update your UI. You could then launch the platform separately for each Y, and put all the reports in a single window. This is probably not a good first project if you are new to JSL though.

 

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

win = New Window( "Select Item(s)",
		<<Modal,
		Text Box( "Item List" ),
		H List Box(
			allcols = Col List Box( dt, all ),
			Lineup Box(
				2,
				V List Box(
					bbAdd = Button Box( "Add", xcols << append( allcols << get selected ) ),
					bbRemove = Button Box( "Remove", xcols << remove selected )
				),
				// Use 'max items()' to only allow one Y to be selected
				xcols = Col List Box( "Numeric", <<Modeling Type( {"Continuous"} ), min items( 2 ))
			),
			V List Box(
				bbOK = Button Box( "OK",
				// 'xvar' is a list
				xvar = (xcols << Get Items);
				str = "";
			 
			
				If( NItems( xvar ) == 0,
					ErrWin = New Window( "Sorry",
						<<modal,
						Text Box( "\!N Please add item at least one \!N\!N" ) 
					)	
				);
				bbCancel = Button Box( "Cancel", Throw() )
			)
		)
	)
	);

dt << Contour Plot(
	X( :height, :weight ),
	Y( Eval(xvar) ),
	Legend( 2 ),
	Show Contours( 1 ),
	Show Data Points( 0 ),
	Fill Areas( 1 ),
	Label Contours( 0 ),
	Color Theme( "Blue White Red" ),
	// You don't need 'Eval(xvar)' here. This usses some contour values from the second variable in 'xvar' for all variables in 'xvar'
	Specify Contours( Min(Column( dt, xvar[2])[5]), Max( Column( dt, xvar[2])[2]), N( 4 ) ),
);

   

LBrian
Level III

Re: Input multiple spec to contour plot using JSL

Thanks to you I can get a hint. I appreciate it.

 

I changed the code slightly.

 

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

win = New Window( "Select Item(s)",
		<<Modal,
		Text Box( "Item List" ),
		H List Box(
			allcols = Col List Box( dt, all ),
			Lineup Box(
				2,
				V List Box(
					bbAdd = Button Box( "Add", xcols << append( allcols << get selected ) ),
					bbRemove = Button Box( "Remove", xcols << remove selected )
				),
				// Use 'max items()' to only allow one Y to be selected
				xcols = Col List Box( "Numeric", <<Modeling Type( {"Continuous"} ), min items( 2 ))
			),
			V List Box(
				bbOK = Button Box( "OK",
				// 'xvar' is a list
				xvar = (xcols << Get Items);
				str = "";
			 
			
				If( NItems( xvar ) == 0,
					ErrWin = New Window( "Sorry",
						<<modal,
						Text Box( "\!N Please add item at least one \!N\!N" ) 
					)	
				);
				bbCancel = Button Box( "Cancel", Throw() )
			)
		)
	)
	);

for(i=1,i<=NItems(xvar),i++,

    dt<<Contour Plot(
	X( :height, :weight ),
	Y( xvar[I] ),
	Legend( 2 ),
	Show Contours( 1 ),
	Show Data Points( 0 ),
	Fill Areas( 1 ),
	Label Contours( 0 ),
	Color Theme( "Blue White Red" ),
	// You don't need 'Eval(xvar)' here. This usses some contour values from the second variable in 'xvar' for all variables in 'xvar'
	Specify Contours( Min(Column( dt, xvar[i])[3]), Max( Column( dt, xvar[i])[4]), N( 4 ) ),
);
);

 

It is not perfect.

but I will use this code for a while and try to update it continuously.

 

Thank you very much.