cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

Saving multiple graphs in JSL

Hi, I'm running this script where dataCols are numeric columns.

OWA = Data Table ("Filtered_raw") << Oneway( 
		Y(eval( dataCols)), 
		X( " WhichTest"),
		Each Pair( 0 ),
		Means( 0 ),
		Plot Actual by Quantile( 0 ),
		Plot Quantile by Actual( 1 ),
		Mean Diamonds( 1 )
);

This creates Oneway Analysis and Normal Quantile plots of my numeric columns. Now I'm trying to save these plots with this script:

OWA << report;
OWA << Save MSWord( "\\snl\home\malepp\Software\JMP\JMP_Report\Oneway_normalQ.doc");

The problem is it only saves the Oneway/Quantile plot from the last column. How do I save all of them to the document?

 

Thanks!

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Saving multiple graphs in JSL

The issue you are running into is that there is not one report output but rather n number of outputs based upon the the actual number of OneWay analyses performed.  So when you do your Save MSWord, it goes one by one saving each output.  However, it does not append the output to the .doc file, but rather replaces it.  So what needs to be done is to place each of the outputs into a JMP Journal, and then save the Journal.  This is what is done in the script below

Names Default To Here( 1 );

// Setup an Example Data table
dt = Open( "$SAMPLE_DATA/blood pressure.jmp" );
dataCols = dt << get column names( continuous );
dt:Dose << set name( "WhichTest" );
dt << set name( "Filtered_raw" );

// Run the charts
OWA = Data Table( "Filtered_raw" ) << Oneway(
	Y( Eval( dataCols ) ),
	X( " WhichTest" ),
	Each Pair( 0 ),
	Means( 0 ),
	Plot Actual by Quantile( 0 ),
	Plot Quantile by Actual( 1 ),
	Mean Diamonds( 1 )
);

// Create a Journal to store the output in
jj = New Window( "The Output", <<journal, vlb = V List Box() );

// Loop across all of the different output in the OneWay and
// copy the output to the journal
For( i = 1, i <= N Items( OWA ), i++,
	vlb << append( Report( OWA[i] )[Outline Box( 1 )] )
);

// Save the journal to disk
jj << Save MSWord( "\\snl\home\malepp\Software\JMP\JMP_Report\Oneway_normalQ.doc" );

jj << close window;
Jim

View solution in original post

Re: Saving multiple graphs in JSL

To add on to @txnelson's reply, you can eliminate the For() loop by sending the Journal message to the list of Oneway objects.  Because OWA represents a list, the Journal message is sent to each item in the list.  Then all you need to do is obtain a reference to the journal using the Current Journal() function.  Below is an altered version of the above example script.

 

Names Default To Here( 1 );

// Setup an Example Data table
dt = Open( "$SAMPLE_DATA/blood pressure.jmp" );
dataCols = dt << get column names( continuous );
dt:Dose << set name( "WhichTest" );
dt << set name( "Filtered_raw" );

// Run the charts
OWA = Data Table( "Filtered_raw" ) << Oneway(
	Y( Eval( dataCols ) ),
	X( "WhichTest" ),
	Each Pair( 0 ),
	Means( 0 ),
	Plot Actual by Quantile( 0 ),
	Plot Quantile by Actual( 1 ),
	Mean Diamonds( 1 )
);

// Create a journal containing each Oneway
OWA << Journal;
// Obtain a reference to the journal
jj = Current Journal();

// Save the journal to disk
jj << Save MSWord( "$DOCUMENTS\Oneway_normalQ.doc" );

jj << Close Window;

 

Wendy

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Saving multiple graphs in JSL

The issue you are running into is that there is not one report output but rather n number of outputs based upon the the actual number of OneWay analyses performed.  So when you do your Save MSWord, it goes one by one saving each output.  However, it does not append the output to the .doc file, but rather replaces it.  So what needs to be done is to place each of the outputs into a JMP Journal, and then save the Journal.  This is what is done in the script below

Names Default To Here( 1 );

// Setup an Example Data table
dt = Open( "$SAMPLE_DATA/blood pressure.jmp" );
dataCols = dt << get column names( continuous );
dt:Dose << set name( "WhichTest" );
dt << set name( "Filtered_raw" );

// Run the charts
OWA = Data Table( "Filtered_raw" ) << Oneway(
	Y( Eval( dataCols ) ),
	X( " WhichTest" ),
	Each Pair( 0 ),
	Means( 0 ),
	Plot Actual by Quantile( 0 ),
	Plot Quantile by Actual( 1 ),
	Mean Diamonds( 1 )
);

// Create a Journal to store the output in
jj = New Window( "The Output", <<journal, vlb = V List Box() );

// Loop across all of the different output in the OneWay and
// copy the output to the journal
For( i = 1, i <= N Items( OWA ), i++,
	vlb << append( Report( OWA[i] )[Outline Box( 1 )] )
);

// Save the journal to disk
jj << Save MSWord( "\\snl\home\malepp\Software\JMP\JMP_Report\Oneway_normalQ.doc" );

jj << close window;
Jim

Re: Saving multiple graphs in JSL

Beautiful! I had tried a similar approach looping through the N Items and trying to append within each loop, but still couldn't make it work. But I wasn't using a Jounal.

 

Any advice with doing the same thing but saving to a PowerPoint? In particular, formatting the ppt? I went with using Word because it gives one analysis per page ( one Oneway and one Normal Quantile Plot, and the titles looked normal). Whereas, with ppt it takes 3 pages for one analysis and the formatting is whacked.

 

Thanks!!!!

 

 

Re: Saving multiple graphs in JSL

To add on to @txnelson's reply, you can eliminate the For() loop by sending the Journal message to the list of Oneway objects.  Because OWA represents a list, the Journal message is sent to each item in the list.  Then all you need to do is obtain a reference to the journal using the Current Journal() function.  Below is an altered version of the above example script.

 

Names Default To Here( 1 );

// Setup an Example Data table
dt = Open( "$SAMPLE_DATA/blood pressure.jmp" );
dataCols = dt << get column names( continuous );
dt:Dose << set name( "WhichTest" );
dt << set name( "Filtered_raw" );

// Run the charts
OWA = Data Table( "Filtered_raw" ) << Oneway(
	Y( Eval( dataCols ) ),
	X( "WhichTest" ),
	Each Pair( 0 ),
	Means( 0 ),
	Plot Actual by Quantile( 0 ),
	Plot Quantile by Actual( 1 ),
	Mean Diamonds( 1 )
);

// Create a journal containing each Oneway
OWA << Journal;
// Obtain a reference to the journal
jj = Current Journal();

// Save the journal to disk
jj << Save MSWord( "$DOCUMENTS\Oneway_normalQ.doc" );

jj << Close Window;

 

Wendy
txnelson
Super User

Re: Saving multiple graphs in JSL

Much better code.........thanks Wendy

Jim