cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
gandi2223
Level III

Contour plot, set X and Y ranges in JSL

When creating a contour plot in JSL, is there a way to set fixed (pre-determined) values for the X and Y maximum and minimum? I.e. to define the area the contour plot will cover, as can be done manually in the X / Y Axis Settings dialogue?

 

My datasets cover different ranges in x and y, but I would like all contour plots to have the same x and y extents.

 

Something like:

Contour Plot(
	X( :X_col, :Y_col ),
	Y( :data ),
	X_minimum(-75000),
	X_maximum(75000)
)

(This obviously does not work.)

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Contour plot, set X and Y ranges in JSL

If you are looking to change the X axis values, not the contour values, they can be set by changing the AxisBox values for the X Axis

.big.PNG

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Little Pond.jmp" );
obj = dt << Contour Plot( X( :X, :Y ), Y( :Z ) );
Report( obj )[AxisBox( 2 )] << Min( 100 ) << Max( 300 );

axis.PNG

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Little Pond.jmp" );
obj = dt << Contour Plot( X( :X, :Y ), Y( :Z ) );
Report( obj )[AxisBox( 2 )] << Min( -100 ) << Max( 400 );

 

 

Jim

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: Contour plot, set X and Y ranges in JSL

The messages that can be sent to the Contour Plot are documented in the Scripting Index, under the Contour Plot selection.  What you are looking for is the Specify Contours message.  The easiest way to get the messages to use, is to run the platform of interest(Contour Plot) with the specifics you want, and then to save the script to a script window.  It will have the JSL required to do the specifics you have requested.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Little Pond.jmp" );
obj = dt << Contour Plot( X( :X, :Y ), Y( :Z ) );
obj << Specify Contours(
	Min( -4 ),
	Max( 8 ),
	N( 4 )
);

 

Jim
gandi2223
Level III

Re: Contour plot, set X and Y ranges in JSL

Thanks for the quick reply, but that sets the Z range, but what I would like to do is set the X-Y extent of the contour plot. I have tried saving the result of the manual process to the script window before, but I ended up with this:

SendToReport(
		Dispatch(
			{},
			"1",
			ScaleBox,
			{Min( -75000 ), Max( 75000 ), Inc( 20000 ), Minor Ticks( 0 )}
		)
	)

I wasn't able to incorporate this in the call of the Contour Plot platform using JSL.

mlo1
Level IV

Re: Contour plot, set X and Y ranges in JSL

mlo1_0-1609622706866.png

Do you mean this by incorporation ?
What does your log window say?

gandi2223
Level III

Re: Contour plot, set X and Y ranges in JSL

This works, but only with the Specify Contours() command. If I take out this line, the log window records:

Cannot find ScaleBox[ "1" ] at {}
Cannot find ScaleBox[ "2" ] at {}

Unfortunately, I do not want to define the contour limits (in Z) manually, I was happy with JMP doing this automatically. My dataset is quite large, and I create several contour plots from it, hence manually calculating the min and max for each and passing it to the Specify Contours() command is possible but a bit awkward.

txnelson
Super User

Re: Contour plot, set X and Y ranges in JSL

If you are looking to change the X axis values, not the contour values, they can be set by changing the AxisBox values for the X Axis

.big.PNG

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Little Pond.jmp" );
obj = dt << Contour Plot( X( :X, :Y ), Y( :Z ) );
Report( obj )[AxisBox( 2 )] << Min( 100 ) << Max( 300 );

axis.PNG

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Little Pond.jmp" );
obj = dt << Contour Plot( X( :X, :Y ), Y( :Z ) );
Report( obj )[AxisBox( 2 )] << Min( -100 ) << Max( 400 );

 

 

Jim
gandi2223
Level III

Re: Contour plot, set X and Y ranges in JSL

Thanks, Jim, that's what I was looking for!

One minor detail - as mentioned, I create multiple plots, using the "By" attribute. So I had to loop over all obj elements:

n = N Items( obj );
For(i = 1, i <= n, i++,
	Report( obj[i] )[AxisBox( 1 )] << Min( -75000 ) << Max( 75000 ) << Inc( 25000 );
	Report( obj[i] )[AxisBox( 2 )] << Min( -75000 ) << Max( 75000 ) << Inc( 25000 );
);

This works, but please let me know in case there is a more elegant way.

txnelson
Super User

Re: Contour plot, set X and Y ranges in JSL

Your approach is a fine way to handle this. Or if you are familiar with the XPath language you could use

( obj << xpath( "//PictureBox//AxisBox[@charID = '1']")) << Min( 100 ) << Max( 300 ) ;
Jim
Jeff_Perkinson
Community Manager Community Manager

Re: Contour plot, set X and Y ranges in JSL

An easy way to do this might be to set the Axis Property for your X and Y columns. That will ensure that every plot made with those columns has the scaling that you want.

 

2021-01-03_13-48-27.778.png

-Jeff