cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
MattH
Level II

How to set auto axis scaling with scripting?

Using JMP 13, how can the axis be set to auto scale using scripting commands.

A snippet of the script code showing a simple variable in place for the min and max. 

	SendToReport(
		Dispatch(
			{},
			"val",
			ScaleBox,
			{Min( Axis_min ), Max( Axis_max ), Inc( 1 ), Minor Ticks( 1 ),
			Add Ref Line( 5, "Dotted", "Medium Dark Red", "5", 4 )}
		),

Goal:  Allow something else (user, script, other) to set the Axis (min and max) specifically or allow the user to pick "Auto".

Searching the guides and reference documents show that it can be set to a numeric value, but do not document any automatic scaling feature.  I hoped that passing "Auto" or a period, or other symbol would work, but they do not.

Also, leaving out the min and max setting line all together to achieve the automatic scaling is not possible as it breaks the goal of allowing something to set the value.

 

Thanks for the help in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
MattH
Level II

Re: How to set auto axis scaling with scripting?

The solution is to use the Revert Axis function.  However, to script this it requires some additional help.

The key is to check the variable being used in the axis setting to see if its a number.  If it's not, then JMP returns a missing value. {see scripting guide, pg68, Chapter 3, under Character Functions. }  This allows a check to be made for something other than a number to reset the axis to an auto scaling, as well as passing a value into the scripting function. 

axisbox(2) is the y axis, and axisbox(1)  is for the x axis.  The Report(gp) is the object handle for the specific graph.

 

if( ( Is Missing(num( A )) | Is Missing(num( B )) ),
	Report(gb)[axisbox(2)] << {Revert Axis};  // axisbox(2) is the y axis
);

It works great.  thanks for the help

 

 

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: How to set auto axis scaling with scripting?

I think what you want to use, is the Revert Axis message.  It sets the axis back to what it automatically calculates for a given Platform.

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( Y( :weight ), X( :height ), FitLine );
rbiv = biv << report;
axisbox = rbiv[axis box( 1 )];
axisbox << Max( 120 );
axisbox << Revert Axis;
Jim
MattH
Level II

Re: How to set auto axis scaling with scripting?

I agree. However, with a slight modification, I can script this to work. I'm posting the details below.
MattH
Level II

Re: How to set auto axis scaling with scripting?

The solution is to use the Revert Axis function.  However, to script this it requires some additional help.

The key is to check the variable being used in the axis setting to see if its a number.  If it's not, then JMP returns a missing value. {see scripting guide, pg68, Chapter 3, under Character Functions. }  This allows a check to be made for something other than a number to reset the axis to an auto scaling, as well as passing a value into the scripting function. 

axisbox(2) is the y axis, and axisbox(1)  is for the x axis.  The Report(gp) is the object handle for the specific graph.

 

if( ( Is Missing(num( A )) | Is Missing(num( B )) ),
	Report(gb)[axisbox(2)] << {Revert Axis};  // axisbox(2) is the y axis
);

It works great.  thanks for the help

 

 

MattH
Level II

Re: How to set auto axis scaling with scripting?

apologies, but I changed the variables from Axis_min to A. Just in case someone doesn't follow from the initial document

Re: How to set auto axis scaling with scripting?

I think that if you remove the Send to Report() argument, then you will not force the specific axis settings and JMP will automatically scale the axis. This argument is used to replicate the settings when you save a script. It it otherwise unnecessary. Jim's idea is the correct solution when specific settings were imposed, but deleting this portion of the script will make that extra step unnecessary.

 

Send to Report() is not the recommended way to script objects. Send messages to the target object instead.