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
davidmingyin
Level I

Can I save each page of a graph(from graph builder) into one separate image file?

I generated lots of pages from one graph. This is from graph builder. 

I like to save each page as one image file. Is this possible in JMP?

 

Thanks,
Dave

6 REPLIES 6
DMD
DMD
Level I

Re: Can I save each page of a graph(from graph builder) into one separate image file?

Yes, this is possible. If you want each graph builder chart saved as an image, it can be scripted for each graph builder chart (or collection of graph builder pages) respectively as:

 

gb << Journal();
current journal() << Save Picture ("\\ImageSaveLocation\ImageName.PNG");
current journal() << Close Window;

gb2 << Journal();
current journal() << Save Picture ("\\ImageSaveLocation\ImageName2.PNG");
current journal() << Close Window;

Anja_W
Level III

Re: Can I save each page of a graph(from graph builder) into one separate image file?

Maybe I don't understand your answer correctly @DMD . Let's say I have a graph builder gb which consists of several pages. Then 

gb << Journal();
current journal() << Save Picture ("\\ImageSaveLocation\ImageName.PNG");
current journal() << Close Window;

saves ONE image with all pages in it. But I want (and this is how I understood @davidmingyin ) several images with each page with its own image. 

I would be really happy if someone can help. Many thanks in advance!

Re: Can I save each page of a graph(from graph builder) into one separate image file?

Hi @davidmingyin -

One way to do this without any scripting is to Export the report as a Powerpoint (File > Export...). To do this in Graph Builder, place a column in the "Page" drop zone. In other analysis platforms, assign a variable to the "By" column role.

When you Export as a Powerpoint, each individual graph will be exported as an image in a separate slide.

-Scott
Craige_Hales
Super User

Re: Can I save each page of a graph(from graph builder) into one separate image file?

Good question. Here's the JSL that can crawl through the display tree to gather the pieces. The journal tree changed between 17 and 18 and might change again. You could probably do the 17 variation on the graphbuilder directly, but I found it easier to work with the journal, especially with the JMP 18 Early Adopter version.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
g = dt << Graph Builder(
	Size( 528, 2956 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ), Page( :age ) ),
	Elements( Points( X, Y, Legend( 5 ) ), Smoother( X, Y, Legend( 6 ) ) )
);

// make a journal just for this task, the vanilla journal might be in use.
tempWindow = New Window( "temp", <<Type( "journal" ) );
g << journal;

// place to save, be careful with delete directory!!!!!!
dir = "$temp/" || "junk/"; // keep the trailing / to join a file name
Delete Directory( dir ); // be careful here! this is really just for testing...
Create Directory( dir );

If( JMP Version() >= "18", // easier in 18, the journal groups the pictures
	// moving the graphs to a journal window is the key; the elements are not
	// grouped by pages in a usable displaybox tree in graphbuilder, but they
	// are when graphbuilder sends them to a journal.
	// now use xpath to extract the chunks you want. In this case, using the
	// journal's showproperties, we discover there is a lineup box whose children
	// are what is needed. Get those children as a list...
	graphList = tempwindow << XPath( "//OutlineBox[text()='Graph Builder']//LineUpBox/ListBox" );
// save the pics; dig out a name for each one
	For Each( {graph}, graphList, 
	// grab a name and keep the non-special characters for a disk file name
		label = Regex( graph[LabelBox( 1 )] << gettext, "[^A-Za-z0-9]+", "_", GLOBALREPLACE );
	// create the individual picture using the label for a filename
		graph << savepicture( dir || label || ".png", "png" );
	);

, // else harder in 17, find a way...
	// at least for this example we find pairs of listboxes, without a listbox wrapper as in 18
	labList = tempwindow << XPath( "//OutlineBox[text()='Graph Builder']//BorderBox//LabelBox" );
	For Each( {lab}, lablist,
		label = Regex( lab << gettext, "[^A-Za-z0-9]+", "_", GLOBALREPLACE );
		parent = lab << parent; // use the journal's property sheet to see what is needed
		spacer = parent << sib;
		graph = spacer << sib;
		combine = V List Box( parent, graph );
		combine << savepicture( dir || label || ".png", "png" );
	);
);


// just for fun, see what happened
fileList = Files In Directory( dir );

For Each( {file}, fileList, Open( dir || file ) );
Craige
Craige_Hales
Super User

Re: Can I save each page of a graph(from graph builder) into one separate image file?

Also, using by groups is about the same as the page option, and will make for easier solutions with xpath. To see the launcher that lets you use a by group in place of page, red-triangle->redo->relaunch

Graph builder also has this traditional launcher dialog, mostly not needed.Graph builder also has this traditional launcher dialog, mostly not needed.

Capture1.PNG

Craige
Craige_Hales
Super User

Re: Can I save each page of a graph(from graph builder) into one separate image file?

Also the by group version works with a data table to hold the graphs

The left-side data table was captured by the command on the right.The left-side data table was captured by the command on the right.

Craige