cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
bensyork
Level I

Reference a scale box with a variable


Hi,

 

I'm trying to produce multiple graphs with a for loop, and assign the column title to the Y axis.

After graphing, I want to add three reference lines to the Y axis with a Dispatch command, but cannot figure out how to dynamically reference the Y axis box, see *** below:

 

For( i = 12, i <= 18, i++,
	Col_name = Column( i ) << Get Name;
	temp = Expr( Col_name );
//Graph Line Data
	Split_dt << Graph Builder(
		Size( 536, 500 ),
		Variables( X( :Year ), X( :Month, Position( 1 ) ), X( :Day, Position( 1 ) ), Y( Column( i ) ) ),
		Elements(
			Box Plot( X( 1 ), X( 2 ), Y, Legend( 9 ), Jitter( 1 ), Outliers( 1 ), Box Style( "Outlier" ) )
		),
		SendToReport(
			Dispatch(
				{},
				,
				ScaleBox,
				{Add Ref Line( 9, Solid, "Black", "LSL" ), Add Ref Line( 21, Solid, "Black", "USL" ),
				Add Ref Line( 16, Dashed, "Medium Dark Green", "Target" )}
			)
		),
		SendToReport(
			Dispatch(
				{},
				"graph title",
				TextEditBox,
				{Set Text( "Line " || Char( Line_Number ) || " " || Col_name )}
			)
		)
	);
);

This code returns the error "Cannot find ScaleBox[ "Col_name" ] at {}", as if JSL is evaluating Col_name as a string.

Any ideas on for to make Col_name evaluate to it's value, or add the ref lines differently?

 

Thanks!

 

3 REPLIES 3
bensyork
Level I

Re: Reference a scale box with a variable

Forgot to add the ***, see below:

 

For( i = 12, i <= 18, i++,
	Col_name = Column( i ) << Get Name;
	temp = Expr( Col_name );
//Graph Line Data
	Split_dt << Graph Builder(
		Size( 536, 500 ),
		Variables( X( :Year ), X( :Month, Position( 1 ) ), X( :Day, Position( 1 ) ), Y( Column( i ) ) ),
		Elements(
			Box Plot( X( 1 ), X( 2 ), And, Legend( 9 ), Jitter( 1 ), Outliers( 1 ), Box Style( "Outlier" ) )
		),
		SendToReport(
			Dispatch(
				{}, 
    
   				ScaleBox,
				{Add Ref Line( 9, Solid, "Black", "LSL" ), Add Ref Line( 21, Solid, "Black", "USL" ),
				Add Ref Line( 16, Dashed, "Medium Dark Green", "Target" )}
			)
		),
		SendToReport(
			Dispatch(
				{},
				"graph title",
				TextEditBox,
				{Set Text( "Line " || Char( Line_Number ) || " " || Col_name )}
			)
		)
	);
);

 

bensyork
Level I

Re: Reference a scale box with a variable

I've discovered a work-around by setting spec limits for the columns I want to graph and setting show as reference lines:

10535_pastedImage_0.png

I still don't know of any way to make the Dispatch function evaluate the variable.  It just takes it as a string.

ian_jmp
Level X

Re: Reference a scale box with a variable

Here's one way to add reference lines to an axis via JSL:

 

Names Default To Here( 1 );
// Make some data and make a graph
dt = New Table( "Test", New Column( "Y", Numeric, Continuous, Formula( Random Normal() ) ), AddRows( 20 ) );
gb = dt << Graph Builder(
	Size( 528, 420 ),
	Show Control Panel( 0 ),
	Variables( Y( :Y ) ),
	Elements( Points( Y, Legend( 16 ) ) ),

);
// Template expression to add a reference line
addRefLine = Expr(
	gb << SendToReport( Dispatch( {}, "Y", ScaleBox, {Add Ref Line( TBD, "Solid", "Black", "", 1 )} ) )
);
// Loop . . .
For( i = -3, i <= 3, i++,
	Wait( 1 );
	Eval( Substitute( Name Expr( addRefLine ), Expr( TBD ), i ) );
);

 

Recommended Articles