Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
shaira
Level IV

Why won't the axis box scripting work if we add "by" in the Bivariate function?

Hi,

I tried a sample script in the guide and found out that when we add "by" in Bivariate plot, we cannot do axis manipulation using jsl. Is there a workaround for this? Thanks.

 

Sample script that works:

Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( X( :height ), Y( :weight ), FitLine );
rbiv = biv << report;
xaxis = rbiv[axis box( 2 )];
yaxis = rbiv[axis box( 1 )];
xaxis << Axis Settings( Show Major Grid( 1 ) );
yaxis << Axis Settings( Decimal( 10, 3 ) );

Sample script that  does not work. Plots are outputted but the axes are not modified.

Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( X( :height ), Y( :weight ), by(:sex), FitLine );
rbiv = biv << report;
xaxis = rbiv[axis box( 2 )];
yaxis = rbiv[axis box( 1 )];
xaxis << Axis Settings( Show Major Grid( 1 ) );
yaxis << Axis Settings( Decimal( 10, 3 ) );

Thanks,
Shaira

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: Why won't the axis box scripting work if we add "by" in the Bivariate function?

The issue is, that you have 2 different graphs being created in the By(:sex) configuration.  You can see this if you run the code and show the value of "biv" after producting the chart or charts.  If you show "biv" in the non By version of the chart, "biv" has the value of:

{Bivariate[]}

If you show() the value of "biv" after the By version you will see:

{Bivariate[], Bivariate[]}

There are 2 sets of chart output.  Therefore, this needs to be handled in the code.  The script below will show you one way to do this:

Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( X( :height ), Y( :weight ), by(:sex), FitLine );

For(i=1,i<=N items(biv),i++,
	rbiv = (biv << report)[i];
xaxis = rbiv[axis box( 2 )];
yaxis = rbiv[axis box( 1 )];
xaxis << Axis Settings( Show Major Grid( 1 ) );
yaxis << Axis Settings( Decimal( 10, 3 ) );
);
Jim

View solution in original post

2 REPLIES 2
Highlighted
txnelson
Super User

Re: Why won't the axis box scripting work if we add "by" in the Bivariate function?

The issue is, that you have 2 different graphs being created in the By(:sex) configuration.  You can see this if you run the code and show the value of "biv" after producting the chart or charts.  If you show "biv" in the non By version of the chart, "biv" has the value of:

{Bivariate[]}

If you show() the value of "biv" after the By version you will see:

{Bivariate[], Bivariate[]}

There are 2 sets of chart output.  Therefore, this needs to be handled in the code.  The script below will show you one way to do this:

Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( X( :height ), Y( :weight ), by(:sex), FitLine );

For(i=1,i<=N items(biv),i++,
	rbiv = (biv << report)[i];
xaxis = rbiv[axis box( 2 )];
yaxis = rbiv[axis box( 1 )];
xaxis << Axis Settings( Show Major Grid( 1 ) );
yaxis << Axis Settings( Decimal( 10, 3 ) );
);
Jim

View solution in original post

Highlighted
shaira
Level IV

Re: Why won't the axis box scripting work if we add "by" in the Bivariate function?

@txnelson, Thanks! Solution is neat and I finally understood  the problem.

Article Labels

    There are no labels assigned to this post.