Saving a graph as an image file without the "graph builder" header in the image. Can someone please advise?
I haven't checked the video but the articles don't address the customer need, "Saving a graph as an image file without the "graph builder" header in the image" using a script and not the user interface. The following function does the trick:
save_graph_only = function({gb, pic_file}, {Default Locals},
rpt = gb << report;
(rpt << Child) << save picture(pic_file);
);
Here is a complete example:
Names Default to Here(1);
save_graph_only = function({gb, pic_file}, {Default Locals},
rpt = gb << report;
(rpt << Child) << save picture(pic_file);
);
pic_file = "$TEMP/graph_no_outline.png";
dt = Open("$SAMPLE_DATA/Iris.jmp");
gb = dt << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :Sepal length ), Y( :Sepal width ), Overlay( :Species ) ),
Elements(
Contour( X, Y, Legend( 3 ), Number of Levels( 3 ) ),
Points( X, Y, Legend( 4 ) )
),
SendToReport(
Dispatch(
{},
"Sepal length",
ScaleBox,
{Min( 4.02451368343195 ), Max( 8.24903846153846 ), Inc( 1 ),
Minor Ticks( 0 )}
),
Dispatch(
{},
"Sepal width",
ScaleBox,
{Min( 1.75 ), Max( 5.00400457665904 ), Inc( 1 ), Minor Ticks( 0 )}
),
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {3, [0, 1, 2], 4, [-1, -1, -1]} ),
Position( {0, 1, 2, -1, -1, -1} )}
)
)
);
save_graph_only(gb, pic_file);
dt << Close Window();
open(pic_file);
Here's a simple way to remove Graph Builder from a graph. You lose the outline box with the little red triangle. If you still want the outline box you can replace Graph Builder with a label of your choosing.
dt = open("$sample_data\Big Class.jmp");
Graph Builder(
Size( 526, 451 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ), Overlay( :sex ) ),
Elements( Line Of Fit( X, Y, Legend( 16 ) ), Points( X, Y, Legend( 17 ) ) ),
SendToReport( Dispatch( {}, "Graph Builder",
OutlineBox, {Set Title( "" )}
)
)
);
If you use the "selection" tool (under the tools menu or the fat plus symbol on your tool bar) you can select just the graph. You can also click on the graph title to edit (or delete).
Hello nlc4. We have a one-page guide describing how to save out graphics from JMP using the technique that karen@boulderstats has outlined. It is available on our learning library: jmp.com/learn or directly here:
You can also see how to do it in this quick video I captured here:
I know this is a really old post, but the link no longer works. Is there an updated link to follow, and does this include information on removing the title/header from within a script, and not just through the user interface?
I haven't checked the video but the articles don't address the customer need, "Saving a graph as an image file without the "graph builder" header in the image" using a script and not the user interface. The following function does the trick:
save_graph_only = function({gb, pic_file}, {Default Locals},
rpt = gb << report;
(rpt << Child) << save picture(pic_file);
);
Here is a complete example:
Names Default to Here(1);
save_graph_only = function({gb, pic_file}, {Default Locals},
rpt = gb << report;
(rpt << Child) << save picture(pic_file);
);
pic_file = "$TEMP/graph_no_outline.png";
dt = Open("$SAMPLE_DATA/Iris.jmp");
gb = dt << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :Sepal length ), Y( :Sepal width ), Overlay( :Species ) ),
Elements(
Contour( X, Y, Legend( 3 ), Number of Levels( 3 ) ),
Points( X, Y, Legend( 4 ) )
),
SendToReport(
Dispatch(
{},
"Sepal length",
ScaleBox,
{Min( 4.02451368343195 ), Max( 8.24903846153846 ), Inc( 1 ),
Minor Ticks( 0 )}
),
Dispatch(
{},
"Sepal width",
ScaleBox,
{Min( 1.75 ), Max( 5.00400457665904 ), Inc( 1 ), Minor Ticks( 0 )}
),
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {3, [0, 1, 2], 4, [-1, -1, -1]} ),
Position( {0, 1, 2, -1, -1, -1} )}
)
)
);
save_graph_only(gb, pic_file);
dt << Close Window();
open(pic_file);
Here's a simple way to remove Graph Builder from a graph. You lose the outline box with the little red triangle. If you still want the outline box you can replace Graph Builder with a label of your choosing.
dt = open("$sample_data\Big Class.jmp");
Graph Builder(
Size( 526, 451 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ), Overlay( :sex ) ),
Elements( Line Of Fit( X, Y, Legend( 16 ) ), Points( X, Y, Legend( 17 ) ) ),
SendToReport( Dispatch( {}, "Graph Builder",
OutlineBox, {Set Title( "" )}
)
)
);
Thanks to you both pmroz and nascif_jmp!
It is honestly hard to pick one for which solution I like best. The addition of
Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "" )}),
is a simple one line of added code solution, and if you need the options just add back in a title. Yet nascif_jmp's function example provides the same clean image, but retains the ability to access the options at a later time without needing to remember to change the script if the user is saving the graph scripts back into the data table.