Scripting FrameBoxes in Graph Builder

If you want to interactively build graphs in JMP then the graph builder platform is great.

I use it a lot when I’m not so familiar with a set of data, and I’m not quite sure how I want to plot the data.  The graph builder allows me to rapidly evaluate different graphical representations.

But when I am scripting that flexibility of the platform becomes a nightmare!  To be honest, most times I will not use the graph builder for scripting.  If I need a scatter plot I will script an overlay plot.   But sometimes the graph builder gives me capabilities that I don’t have in other platforms.  Often I want to utilise the “wrap” property to create trellis plots:

JMP Graph Builder Wrap PropertyThese are great until we want to exercise greater control on them through our scripts.  After all, isn’t that the point of scripting?

In scripting terminology each “tile” of the trellis plot is a frame box.  This is a display box that has properties associated with the graphical elements.  So for example, if I want to increase the marker size then I send a message to the frame box.

Let’s try it:

dt = Open( "$SAMPLE_DATA/big" );
gb = dt << Graph Builder(
    Show Control Panel( 0 ),
    Variables( X(:height), Y(:weight), Wrap(:age )),
reportWindow = gb << Report;
reportWindow[ FrameBox(1) ] << Marker Size(6);

I’ve highlighted the important line where the marker size message is sent to the frame box.  This is the outcome:

marker size property applied to the first frame of the trellis plotWell I got exactly what I requested, but it’s not what I want.  I need to apply the marker size individually to each frame box.  And the boxes are indexed 1,2, etc. up to the maximum number of tiles of the trellis plot.  And that’s the problem.  The number of frame boxes is data dependent.  So now I need to calculate the number of distinct levels of my classification variable (age in this example) – or do I?

Here is a much simpler technique.  I send the marker size message  to the first frame box, then the second, and so on.  At some point I will send the message to a frame box that doesn’t exist.  That’s OK.  We’re allowed to perform invalid tasks in a script so long as we anticipate that an error can occur, which we do by using a “try block”.  Basically I am going to say the following to JMP: “try and do this, if you can’t then I guess I have come to the end of all the frame boxes”.  This is how it is written in JSL:

haveFrameBox = 1;
i = 0;
        reportWindow[FrameBox(i)] << Marker Size(6);
        haveFrameBox = 0

Let me paraphrase the code again:

“While I have a frame box I will try and send the marker size message.  If I try and send the message and get an error then I will set a variable to indicate that I no longer have a frame box”

This is the outcome:

JMP trellis plot with the marker size applied to all frame boxesSuccess!

6 thoughts on “Scripting FrameBoxes in Graph Builder”

  1. Hi David, this was very helpful. I agree with your comments about scripting the Graph Builder, not so intuitive but gives nice 5×5 maps which is useful for the semiconductor industry. I used your example with a small modification to set the Frame Size which then updated for all boxes as they all have to be the same size in one plot!

    Kind regards,


  2. Hi David, it’s very interesting the try block. However, I came here looking for another solution. Would you know how to change the marker size of one graph that is already opened by scripting? How would I use in that case this code: “reportWindow = gb << Report;"?


    1. For my question, Window(“Window”)[FrameBox(i)] can be used. Now I wonder how to do the same in a Scatterplot 3D to change, for example, the colorbar.

  3. This is really helpful. I have another script to share for this same purpose:

    Figure1 = dt << Graph Builder(…………………………
    (Report(Figure1) << xpath("//FrameBox")) << Marker Size( 6 );

Leave a Reply

Your email address will not be published. Required fields are marked *