Subscribe Bookmark RSS Feed

Change axis or legend with a button

rhakim_gmail_co

Community Trekker

Joined:

Aug 7, 2015

I have a JSL script consisting of several buttons. Each button opens a new window with a bivariate time trend with a unique time and legend from my dataset, i.e.

VALUE     TIME@A     LEGEND@A     TIME@B     LEGEND@B

--------------------------------------------------------------------------------------------------

10                 1                    A                    2                   B       

40                 2                    B                    3                   C

50                 3                    A                    4                   C

30                 4                    B                    5                   B

Button #1 opens Value (Y) by Time1 (X), with Legend = Legend1, button #2 opens Value (Y) by Time2 (X), with Legend = Legend2.

In my actual dataset I have much more than 2 time/legend pairs that I need to check - I wanted to know if there's a way in JSL to change the x axis/legend on the same plot with a click of a button, instead of opening a new window every time?

I tried the following just to change the axis, but it doesn't work. Didn't even try changing the legend yet... Thanks in advance!

dt = open("data.jmp");

ColA = Column("TIME@A");

ColB = Column("TIME@B");

nw = new window("NewWin",

     hlistbox(

          bv = Bivariate(

               Y( :Name( "VALUE" ) ),

               X( ColA )

          ),

          Button box(

               "Change axis",

               bv << X( ColB )

          )

     );

);

3 REPLIES
ms

Super User

Joined:

Jun 23, 2011

I am not sure it is possible to change the axis only. However, one way to avoid opening a new window is to simply delete the entire plot and add the updated plot in its place.

For example:

dt = Open("$SAMPLE_DATA/Big Class.jmp");

ColA = Column("height");

ColB = Column("age");

make_bv = Function({col},

    bv = Bivariate(Y(:Name("weight")), X(col))

);

          

nw = New Window("NewWin",

    hlb = H List Box(

        make_bv(ColA);

        Button Box("Change axis",

            bv << delete; // delete plot

            hlb << prepend(make_bv(ColB)); // add updated plot

        );

    )

);

rhakim_gmail_co

Community Trekker

Joined:

Aug 7, 2015

Great - it worked! Based on this I also managed to add a legend input to the function, so it switches that too :-) Thanks a lot!

ms

Super User

Joined:

Jun 23, 2011

Or alternatively, make use of the built-in column switcher functionality:

dt = Open("$SAMPLE_DATA/Big Class.jmp");

nw = New Window("NewWin",

    hlb = H List Box(

        bv = Bivariate(Y(:weight), X(:height));

        cs = bv << Column Switcher(:height, {:height, :age});

        Button Box("Change axis", cs << next); // button works but not needed

    )

);