Subscribe Bookmark RSS Feed

Unlink data in Overlay Plot from data table

terapin

Community Trekker

Joined:

Jun 23, 2011

I've dug through the Scripting Guide looking for a way to "break" the linkage between the data displayed in an overlay plot and its' data table but can't seem to find out how to do this.  The reason is that I want to create multiple OPs with various user specified date ranges of data.  I'm using a data filter to select the date ranges I'm interested in so that the resultant OPs can autoscale the x and y axis data so that I don't have to specify these parameters since they dramatically change over the year. 

To simplify the issue I've included some mocked up code below that is basically showing what I'm trying to accomplish: Namely, create 2 OPs that show data for Months 1-3 AND 5-7 and have each of these OPs be unlinked from the original data so that as the data selected from the data filter changes, the data shown in the OP doesn't change from what was originally specified.  Any suggestions on how to accomplish this would be greatly appreciated. 

Clear Log();

dt = Open( "C:\Program Files\SAS\JMP\10\Samples\Data\Time Series\Raleigh Temps.JMP" );

sdate = 1;

edate = 3;

obj = dt << Data Filter(

    Auto Clear ( 1 ),

    Show Window ( 0 ),

    Add Filter(

        columns( :Name( "Month" ) ),

        Where(

            :Name( "Month" ) >= sdate & :Name( "Month" ) <=

            edate

        )

    ),

    Mode( Show( 1 ), Include( 1 ) )

);

obj << Close;

Overlay Plot(

    X( :Name( "Month" ) ),

    Y( :Name( "Temperature" ) ),

    Separate Axes( 1 ),

    Connect Thru Missing( 1 ),

    Connect Points( 1 ),

    SendToReport(

        Dispatch(

            {},

            "101",

            ScaleBox,

            {Show Major Grid( 1 ), Rotated Labels( "Automatic" )}

        )

    )

);

sdate = 5;

edate = 7;

obj = dt << Data Filter(

    Auto Clear ( 1 ),

    Show Window ( 0 ),

    Add Filter(

        columns( :Name( "Month" ) ),

        Where(

            :Name( "Month" ) >= sdate & :Name( "Month" ) <=

            edate

        )

    ),

    Mode( Show( 1 ), Include( 1 ) )

);

obj << Close;

Overlay Plot(

    X( :Name( "Month" ) ),

    Y( :Name( "Temperature" ) ),

    Separate Axes( 1 ),

    Connect Thru Missing( 1 ),

    Connect Points( 1 ),

    SendToReport(

        Dispatch(

            {},

            "101",

            ScaleBox,

            {Show Major Grid( 1 ), Rotated Labels( "Automatic" )}

        )

    )

);

8 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Correct me if I am wrong, but I don't think it's possible to break the link between a platform and the data table. The plot has to be moved out of the platform, e.g. to a journal or to a new window.

Bothe methods are used In this example. The two filtered overlay plots is both sent to the same journal or to individual windows.

Clear Log();

dt = Open( "$SAMPLE_DATA\Time Series\Raleigh Temps.JMP" );

// Data filter expression

filter_expr = Expr(

  obj = dt << Data Filter(

  Auto Clear( 1 ),

  Show Window( 0 ),

  Add Filter(

  columns( :Name( "Month" ) ),

  Where( :Name( "Month" ) >= sdate & :Name( "Month" ) <= edate )

  ),

  Mode( Show( 1 ), Include( 1 ) )

  );

  obj << Close;

);

// Overlay Plot

overlay = Expr(

  op = Overlay Plot(

  X( :Name( "Month" ) ),

  Y( :Name( "Temperature" ) ),

  Automatic recalc( 0 ),

  Separate Axes( 1 ),

  Connect Thru Missing( 1 ),

  Connect Points( 1 ),

  SendToReport( Dispatch( {}, "101", ScaleBox, {Show Major Grid( 1 ), Rotated Labels( "Automatic" )} ) ),

  invisible

  )

);

// First plot

sdate = 1; edate = 3; filter_expr; overlay;

// New window...

nw = New Window( "Month " || Char( sdate ) || "-" || Char( edate ), Report( op )[1] );

// or Journal

op << journal;

// Second plot

sdate = 5; edate = 7; filter_expr; overlay;

nw = New Window( "Month " || Char( sdate ) || "-" || Char( edate ), Report( op )[1] );

op << journal;

mpb

Super User

Joined:

Jun 23, 2011

This example may provide a slightly different perspective.

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

lo = 9;

hi = 11;

Overlay Plot(

    X( :Runtime ),

    Y( :Oxy ),

    Where( :Runtime >= lo & :Runtime <= hi )   

);

lo = 10;

hi = 12;

Overlay Plot(

    X( :Runtime ),

    Y( :Oxy ),

    Where( :Runtime >= lo & :Runtime <= hi )

);

terapin

Community Trekker

Joined:

Jun 23, 2011

Thanks folks for the suggestions.  Both are interesting approaches to the problem.  However, neither work for my specific application since I want to create multiple OP's in a single VListBox window (Sorry, I wasn't clear about that in my original post).  I can't seem to figure out how to make either of your approaches work to do this.  Any ideas?

New Window(

     V List Box(

          Op1 = Overlay Plot(.....),

          Op1 = Overlay Plot(.....)

     )

);

mpb

Super User

Joined:

Jun 23, 2011

Here's one possibility using the journal idea.

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

lo = 9;

hi = 11;

op1 = Overlay Plot(

    X( :Runtime ),

    Y( :Oxy ),

    Where( :Runtime >= lo & :Runtime <= hi ) 

);

report(op1)<<journal();

jrn = current journal();

lo = 10;

hi = 12;

op2 = Overlay Plot(

    X( :Runtime ),

    Y( :Oxy ),

    Where( :Runtime >= lo & :Runtime <= hi )

);

jrn << append(report(op2));

mpb

Super User

Joined:

Jun 23, 2011

Or using the New Window idea:

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

New Window( "My Window",

    Outline Box( "My Outline Box",

        V List Box(

            lo = 9;

            hi = 11;

            op1 = Overlay Plot(

                X( :Runtime ),

                Y( :Oxy ),

                Where( :Runtime >= lo & :Runtime <= hi )

            );,

            lo = 10;

            hi = 12;

            op2 = Overlay Plot(

                X( :Runtime ),

                Y( :Oxy ),

                Where( :Runtime >= lo & :Runtime <= hi )

            );           

        )

    )

);

Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

In JMP 10 you can use a Local Data Filter that lets you filter without disturbing the original data table.

I would also suggest using Graph Builder instead of Overlay Plot.

Here's an example:

dt = Open( "$SAMPLE_DATA\Time Series\Raleigh Temps.JMP" );

New Window( "My Window",

  V List Box(

  dt << Graph Builder(

  Variables( X( :Name( "Month/Year" ) ), Y( :Temperature ) ),

  Elements( Line( X, Y, Legend( 4 ), Row order( 0 ), Summary Statistic( "Mean" ) ) ),

  Local Data Filter(

  Location( {207, 385} ),

  Add Filter( columns( :Year ), Where( :Year >= 1980 & :Year <= 1982 ) ),

  Mode( Select( 0 ), Show( 1 ), Include( 1 ) )

  )

  );

  dt << Graph Builder(

  Size( 570, 518 ),

  Variables( X( :Name( "Month/Year" ) ), Y( :Temperature ) ),

  Elements( Line( X, Y, Legend( 4 ), Row order( 0 ), Summary Statistic( "Mean" ) ) ),

  Local Data Filter(

  Location( {207, 385} ),

  Add Filter( columns( :Year ), Where( :Year >= 1982 & :Year <= 1990 ) ),

  Mode( Select( 0 ), Show( 1 ), Include( 1 ) )

  )

  );

  )

);

-Jeff
terapin

Community Trekker

Joined:

Jun 23, 2011

Thanks Jeff for your assistance on this.  I appreciated the Graph Builder suggestion.  That probably won't work in my particular case since I'm dealing with a graphical display matrix of 2 columns by 6 rows and the Graph Builder overhead takes up too much space.  However, it's great to see this example for future graphs that aren't as large and in which having some interactive capabilities would be helpful.

Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

If you're concerned about space, you may be thinking of the control panel that Graph Builder shows by default, but you can turn that off with Show Control Panel(0).

And, if you can encode your your conditions into a column you can use the Group X and Group Y roles to make a fairly compact display.

In the example below I create a column indicating Company Size to encode my conditions.

dt = Open( "$SAMPLE_DATA\Financial.jmp" );

dt << New Column( "Company Size", Formula( If( :Name( "#emp" ) < 10000, "Small", "Large" ) ) );

dt << Graph Builder(

  Size( 638, 770 ),

  Show Control Panel( 0 ),

  Variables(

  X( :Name( "Assets($Mil.)" ) ),

  Y( :Name( "Sales($M)" ) ),

  Group X( :Company Size ),

  Group Y( :Type )

  ),

  Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )

);

-Jeff