cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
seanschubert
Level I

Script to globally change Axis increment

I need a script to change the Axis increment to 0.1 and # Minor Ticks to 0 for all 168 distributions in my analysis.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Script to globally change Axis increment

Here is a script that will work, providing the data table the distributions were run on is the current active data table, and the distributions are either the only distributions window, or else it was the last distributions window you had viewed

Names Default To Here( 1 );

// Find the window with the Distributions

For( i = 1, i <= N Items( Window() ), i++,

       Show( i, Window( i ) << get window title );

       If( Char( Word( -1, Window( i ) << get window title ) ) == "Distribution",

              dist = Window( i );

              Break();

       );

);

// Find the current data table to get a list of all possible continuous columns

dt = Current Data Table();

// Get the list of columns

collist = dt << get column names( string, continuous );

// Do a brute strength pass throug all columns in the data table and

// attempt to change the axis settings

For( i = 1, i <= N Items( collist ), i++,

       Eval( Substitute( Expr( Try( dist[1][__col__][axis box( 1 )] << inc( .1 ) ) ), Expr( __col__ ), collist[i] ) );

       Eval( Substitute( Expr( Try( dist[1][__col__][axis box( 1 )] << show minor ticks( 0 ) ) ), Expr( __col__ ), collist[i] ) );

);

Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Script to globally change Axis increment

Here is a script that will work, providing the data table the distributions were run on is the current active data table, and the distributions are either the only distributions window, or else it was the last distributions window you had viewed

Names Default To Here( 1 );

// Find the window with the Distributions

For( i = 1, i <= N Items( Window() ), i++,

       Show( i, Window( i ) << get window title );

       If( Char( Word( -1, Window( i ) << get window title ) ) == "Distribution",

              dist = Window( i );

              Break();

       );

);

// Find the current data table to get a list of all possible continuous columns

dt = Current Data Table();

// Get the list of columns

collist = dt << get column names( string, continuous );

// Do a brute strength pass throug all columns in the data table and

// attempt to change the axis settings

For( i = 1, i <= N Items( collist ), i++,

       Eval( Substitute( Expr( Try( dist[1][__col__][axis box( 1 )] << inc( .1 ) ) ), Expr( __col__ ), collist[i] ) );

       Eval( Substitute( Expr( Try( dist[1][__col__][axis box( 1 )] << show minor ticks( 0 ) ) ), Expr( __col__ ), collist[i] ) );

);

Jim
seanschubert
Level I

Re: Script to globally change Axis increment

Thanks Jim.

It worked like a charm.

- Sean

mikedriscoll
Level VI

Re: Script to globally change Axis increment

This question is pretty much answered but I'll post this anyway....

I run this script every time I run the distribution platform, or if I scale the axis manually (which changes the inc / tick settings). I should probably just set it up so it always runs by default after the distribution platform but it's not a big deal. I have it set up within an add-in toolbar, a custom set of scripts.  So I just click on it after the distributions show up, and it runs right from there. Because of that, the 3rd line probably isn't necessary.  You could modify it with your inc() needs or whatever.

This works in the main distribution platform as well as when distributions are appended in a custom scripted window.  I've found it does not work for fit y by x when adding histograms to the axes. I'm sure I could get it to work, I just haven't really needed it.

I did a loop to 3000 with a try( , break) as a brute force but it could be done more elegantly like Jim has done. Or use xcode which i've never been able to *really* figure out.

Names Default To Here( 1 );

myrpt = current report();

myrpt << bring window to front;

for(i = 1, i < 3000, i++,

      try(myrpt[AxisBox(i)] << minor ticks(5), break());

);

If anyone is wondering why go through the trouble, it is because JMP plots histograms like this (notice how tight the data actually is vs the wide histo bins).  Even when the data is scaled more appropriately to limits (these are wide limits), the bins are too wide for my liking.

11775_pastedImage_7.png

After running the script:

11776_pastedImage_8.png

-Mike

Re: Script to globally change Axis increment

You could also write a short utility script to add the Axis column property with the desired settings so that ALL plots in any platform would have such a scale.

I believe that the correct syntax is:

:col << Get Property( "Axis",

  {Min( 11 ), Max( 18 ), Inc( 0.5 ),

  Minor Ticks( 0 ), Show Major Ticks( 1 ),

  Show Minor Ticks( 1 ), Show Major Grid( 0 ),

  Show Minor Grid( 0 ), Inside Ticks( 0 ),

  Show Labels( 1 ),

  Rotated Labels( "Automatic" ),

  Scale( "Log" ), Add Ref Line( 13 )}

);