- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
how to automate the exporting of grouped graphs to .jpg with scripting
hi, all
how to automate the exporting of grouped graphs to .jpg with scripting? any helps and hints will be appreciated.
I used the sample data animals to illustrate what I what to do. I plot the data like below. I intend to export each graph/plot with the title part and legend into a single .jpg or whatever format with scripting.
1stly, In my data, I do not know how many plots will be plotted before hand. 2nd thing is that I am not familiar the construct of the plots, and how to handle them one by one in jmp script.
Oneway(
Y( :miles ),
X( :season ),
All Graphs( 0 ),
Plot Quantile by Actual( 1 ),
Line of Fit( 0 ),
X Axis Proportional( 0 ),
Grand Mean( 0 ),
By( :species )
);
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to automate the exporting of grouped graphs to .jpg with scripting
Open( "$sample_data/animals.jmp" );
p = Oneway(
Y( :miles ),
X( :season ),
All Graphs( 0 ),
Plot Quantile by Actual( 1 ),
Line of Fit( 0 ),
by( species )
);
// p is a { list } of platforms, 1 per by group value
For( ip = 1, ip <= N Items( p ), ip++,
r = Report( p[ip] ); // get the report
image = r << getpicture;
image << savepicture( "$temp/picture" || Char( ip ) || ".png", "png" );
Open( "$temp/picture" || Char( ip ) || ".png" );
);
and
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to automate the exporting of grouped graphs to .jpg with scripting
Open( "$sample_data/animals.jmp" );
p = Oneway(
Y( :miles ),
X( :season ),
All Graphs( 0 ),
Plot Quantile by Actual( 1 ),
Line of Fit( 0 ),
by( species )
);
// p is a { list } of platforms, 1 per by group value
For( ip = 1, ip <= N Items( p ), ip++,
r = Report( p[ip] ); // get the report
image = r << getpicture;
image << savepicture( "$temp/picture" || Char( ip ) || ".png", "png" );
Open( "$temp/picture" || Char( ip ) || ".png" );
);
and
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to automate the exporting of grouped graphs to .jpg with scripting
Thanks,Craig!
Would it be possible to name the pictures by the title of the plots? As in my data, there are more than 20 combinations and it is hard to find the picture interested without this kind of naming convention.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to automate the exporting of grouped graphs to .jpg with scripting
Sure. Note the regex that sanitizes the file name...you might want to adjust it for your needs. As shown, it converts all odd looking character (spaces and equal sign in this case) to underscore. Windows is probably OK with both of those, but they don't help some programs.
Open( "$sample_data/animals.jmp" );
p = Oneway(
Y( :miles ),
X( :season ),
All Graphs( 0 ),
Plot Quantile by Actual( 1 ),
Line of Fit( 0 ),
by( species )
);
// p is a { list } of platforms, 1 per by group value
For( ip = 1, ip <= N Items( p ), ip++,
r = Report( p[ip] ); // get the report
image = r << getpicture; // r *is* the outline
title = (r << gettitle); // use the outline name
// you *might* want to replace problematic characters:
title = Regex( title, "[^a-zA-Z0-9]", "_", GLOBALREPLACE );
path = "$temp/" || title || ".png";
image << savepicture( path, "png" );
Open( path );
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to automate the exporting of grouped graphs to .jpg with scripting
Craig
Thank you again for timely response and solving the problem for me.
Is there a document or a way to check the architecture of the grouped plots, i.e. how to understand the tree structure and hierarchy of it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to automate the exporting of grouped graphs to .jpg with scripting
Use the ShowTreeStructure command from the outer-most outline's open/close triangle:
You'll get a view of the displaybox tree that makes up the report:
For the by-group case, there is actually a listbox that holds all the reports together. You don't see it in the ShowTreeStructure output because it is outside of the report that you clicked on. In the example JSL, the JSL list holds all the platforms. A platform is created for each by group, and a platform roughly corresponds to the red triangle. The red triangle and the platform object both give you access to commands the platform understands (like "add a fitted line to the graph", etc) In the example JSL, the loop runs over the platforms in the list and asks each platform for its displaybox tree (the report function). That displaybox tree is what you see in the ShowTreeStructure output.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to automate the exporting of grouped graphs to .jpg with scripting
hi, Craig
how about the plots in graph builder? using same sample data plots as below. Please help me how do I call out the boxes in graph builder. I think its construct is different than that of by-group plots.
Graph Builder(
Fit to Window( "Off" ),
Graph Spacing( 3 ),
Spacing Borders( 1 ),
Variables( X( :season ), Y( :miles ), Group X( :subject ), Group Y( :species ) ),
Elements( Points( X, Y, Legend( 13 ) ) )
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to automate the exporting of grouped graphs to .jpg with scripting
You could use the picture box to take a complete picture of a graph builder.
Use a data filter if you need separate pictures of graphs of different subsets.
gb = Graph Builder(
Size( 522, 444 ),
Show Control Panel( 0 ),
Variables( X( :season ), Y( :miles ) ),
Elements( Points( X, Y, Legend( 10 ) ) )
);
gb<< Local Data Filter(
columns( :species, :subject ),
Where( :species == "COYOTE" ),
Where( :subject == 2 )
);
gb<<remove local data filter;
gb<< Local Data Filter(
columns( :species, :subject ),
Where( :species == "FOX" ),
Where( :subject == 1 )
);
report(gb)[pictureBox(1)] << savePicture("$temp/delememe.png", "png");
open("$temp/delememe.png");