Subscribe Bookmark RSS Feed

Send commands to multiple Bivariate Plots

nikles

Community Trekker

Joined:

Mar 4, 2013

I have a script that generates a series of bivariate plots within a single window, using a LineUpBox to contain each plot.  After the plots have been created, I want the option for the user to toggle on/off the points of the plot (I intend to add other options...this is serving only as one example).  I envision a buttonbox or checkbox in the window the user can click on, and all the plots will reflect this action. 

 

For a single plot, I would use the command:

bvp << Show Points(0/1);

where bvp is the reference to the bivariate plot.  However, here I have multiple plots and cannot use a single reference for them all.  I tried referencing to my LineUpBox that contains the plots instead:

For(plid = 1, plid <= nplots, plid++,
 LUB_plots[plid] << Show Points(pts)
)

 

 

where LUB_plots is the reference to my lineupbox.   This loop would be run each time the user checks the checkbox, for example.  When I do this, I get the following errors:

The display box 'OutlineBox' does not recognize the message 'Show Points'; perhaps you mean one of these:  <<Show Properties <<Show HelpKeys <<SetHorizontal <<Horizontal <<SetOpen <<GetHorizontal <<Close Where No Outlines <<Font <<Set Font <<Set Font Style <<Set Font Size <<Reshow <<Set Report Title <<Set Window Title <<Top Parent <<Show Tree Structure <<Restore Window Size <<Set Window Size <<Set Content Size <<Get Window Position <<Show Window <<Get Show Window <<Set Window Title <<Set Window Icon <<Set Print Headers <<Set Print Footers <<Scroll Window <<Set Width <<Set Height <<Horizontal Alignment.

and an instance of the following for each plot:

(The following message might not be an actual error; the preference 'Report Invalid Display Box Messages' is ON.) The display box 'OutlineBox' does not recognize the message 'Show Points'.

 

I checked the tree structure and confirm that yes, the top display box is indeed an outline box.  So at least I know LineUpBox[plid] is aiming where I expected it to.  The problem seems to be that my <<Show Points command sees the outline box it's pointed to, but fails to recognize that the outline box is actually part of a bivariate plot.

 

My question: How can I reference multiple bivariate plots?  Alternatively, is there a better way to send commands to multiple bivariate plots after they've been created?  Perhaps using some sort of Dispatch/SendtoReports command structure?

 

Not sure how to even search the community for this one.  Any help is appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
ms

Super User

Joined:

Jun 23, 2011

Solution

Or much simpler with xpath, inspired by a JMP Summit presentation that just was posted here:

Names Default To Here(1);
//Example report
Open("$SAMPLE_DATA/Big Class.jmp");
nw = New Window("example",
    lub = Lineup Box(
        Bivariate(Y(:weight), X(:height), FitLine()),
        Bivariate(Y(:weight), X(:age), FitLine()),
        Bivariate(Y(:age), X(:age), FitLine()),
        Bivariate(Y(:weight), X(:weight), FitLine())
    )
);

//Make list of plots
L = (lub << xpath("//LineUpBox/OutlineBox")) << get scriptable object;

// Send messages to all plots, e.g
L << show points(0);
 

 

5 REPLIES
ms

Super User

Joined:

Jun 23, 2011

The show points() message needs to be sent to the Bivariate object rather than to its top display box. From an existing display tree, a reference to the associated object can be obtained by <<Get Scriptable Object.

 

An example that also illustrates one way to send messages to multiple plots:

Names Default To Here(1);
//Example report
Open("$SAMPLE_DATA/Big Class.jmp");
New Window("example",
    lub = Lineup Box(
        Bivariate(Y(:weight), X(:height), FitLine()),
        Bivariate(Y(:weight), X(:age), FitLine()),
        Bivariate(Y(:age), X(:age), FitLine()),
        Bivariate(Y(:weight), X(:weight), FitLine())
    )
);

//Make list of plots (here top-level Outline boxes)
L = {};
i = 1;
While(Is Scriptable(Try(lub[Outline Box(i)])),
    If((lub[Outline Box(i)] << parent) << classname == "LineUpBox",
        Insert Into(L, lub[Outline Box(i)] << get scriptable object)
    );
    i++;
);

// Send messages to all plots, e.g
L << show points(0);
ms

Super User

Joined:

Jun 23, 2011

Solution

Or much simpler with xpath, inspired by a JMP Summit presentation that just was posted here:

Names Default To Here(1);
//Example report
Open("$SAMPLE_DATA/Big Class.jmp");
nw = New Window("example",
    lub = Lineup Box(
        Bivariate(Y(:weight), X(:height), FitLine()),
        Bivariate(Y(:weight), X(:age), FitLine()),
        Bivariate(Y(:age), X(:age), FitLine()),
        Bivariate(Y(:weight), X(:weight), FitLine())
    )
);

//Make list of plots
L = (lub << xpath("//LineUpBox/OutlineBox")) << get scriptable object;

// Send messages to all plots, e.g
L << show points(0);
 

 

nikles

Community Trekker

Joined:

Mar 4, 2013

Thanks!  The xpath cmd works great for my show points example.

 

Now I have a followup.  How can I send a command to all my plots that changes the y-axis from linear to log?  As a start, I tried using the xpath command with the intent of creating a list of all references to all the y-axis boxes. I'm first just trying to confirm that the xpath command is pulling the correct refs.  But I can't seem to get it to return just those boxes though.  By inspecting the xml code in the log, I could see the y-axis boxes all have a "charID=\!"2\!"", so I'm trying to use that to differentiate the y's from the x's, but no luck. 

Names Default To Here(1);

//Example report
Open("$SAMPLE_DATA/Big Class.jmp");
Try(Window("example") << Close Window);
nw = New Window("example",
    lub = Lineup Box(
        Bivariate(Y(:weight), X(:height), FitLine()),
        Bivariate(Y(:weight), X(:age), FitLine()),
        Bivariate(Y(:age), X(:age), FitLine()),
        Bivariate(Y(:weight), X(:weight), FitLine())
    )
);

Show(lub << Get xml); Show(lub << xpath("//AxisBox")); //list of 8 displayboxes Show(lub << xpath("//AxisBox[2]")); //empty list Show(lub << xpath("//AxisBox['2']")); //list of 8 displayboxes Show(lub << xpath("//AxisBox[\!"2\!"]")); //list of 8 displayboxes Show(lub << xpath("//AxisBox[charID=\!"2\!"]")); //empty list Show(lub << xpath("//AxisBox[\!"charID=2\!"]")); //list of 8 displayboxes

How can I get xpath to return just the 4 y axisboxes?

 

Once I succeed in generating the references to the specific axis boxes I want, do I need to send the "Get Scriptable Object" command as with your previous example, or can I just send the "Scale" command directly to the list of references?

 

I read through the JMP Summit presentation and the .jsl code examples you provided...very helpful.  However, additional documentation is sparse in the Scripting Index, and appears to be non-existent in Scripting Guide.  Is there more documentation available on xpath?  I'd like to know what the format is for the input.  For example, what does the "//" do at the beginning?  And how should I format the rest of the input to get the displayboxes I need? 

 

Thanks.

ms

Super User

Joined:

Jun 23, 2011

This syntax seems to work:

y_axes = (lub << xpath("//AxisBox[@charID='2']"));
y_axes << scale(Log);

For xpath documentation, see for example w3schools tutorial on XPath

nikles

Community Trekker

Joined:

Mar 4, 2013

Thanks again.  Elegant.