cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
natalie_
Level V

How can I use JSL to create an "Overlay Plot" with data series?

Hi all,

I would like to create an overlay plot with multiple data series.  I see how I can copy the script and paste it into my code, but what if I don't know in advance how many columns I will have?  Also, what can I do about using different markers as well?

Here is a copy of my script.  This is one of my smaller files, so naturally I would't want to have to type in all those lines!  Thanks in advance.

Overlay Plot(

  X( :Drain_Voltage ),

  Y(

  :Y_17,

  :Y_18,

  :Y_19,

  :Y_20,

  :Y_21,

  :Y_22,

  :Y_23,

  :Y_24,

  :Y_25,

  :Y_26,

  :Y_27,

  :Y_28,

  :Y_29,

  :Y_30,

  :Y_31,

  :Y_32,

  :Y_33,

  :Y_34,

  :Y_35,

  :Y_36,

  :Y_37,

  :Y_38,

  :Y_39

  ),

  Overlay Axis << {{Min( 0.01 ), Max( 100 ), Inc( 1 ), Minor Ticks( 1 )}},

  :Y_17( Overlay Marker( 8 ) ),

  :Y_18( Overlay Marker( 1 ) ),

  :Y_20( Overlay Marker( 2 ) ),

  :Y_21( Overlay Marker( 5 ) ),

  :Y_22( Overlay Marker( 6 ) ),

  :Y_23( Overlay Marker( 17 ) ),

  :Y_24( Overlay Marker( 7 ) ),

  :Y_25( Overlay Marker( 11 ) ),

  :Y_26( Overlay Marker( 3 ) ),

  :Y_27( Overlay Marker( 18 ) ),

  :Y_28( Overlay Marker( 19 ) ),

  :Y_29( Overlay Marker( 24 ) ),

  :Y_30( Overlay Marker( 25 ) ),

  :Y_31( Overlay Marker( 26 ) ),

  :Y_32( Overlay Marker( 27 ) ),

  :Y_33( Overlay Marker( 28 ) ),

  :Y_34( Overlay Marker( 29 ) ),

  :Y_35( Overlay Marker( 30 ) ),

  :Y_36( Overlay Marker( 31 ) ),

  :Y_37( Overlay Marker( 9 ) ),

  :Y_38( Overlay Marker( 10 ) ),

  :Y_39( Overlay Marker( 8 ) ),

  SendToReport(

  Dispatch(

  {},

  "102",

  ScaleBox,

  {Min( 0.01 ), Max( 100 ), Inc( 1 ), Minor Ticks( 1 )}

  ),

  Dispatch( {}, "", AxisBox, {Add Axis Label( "Idleak (uA)" )} ),

  Dispatch( {}, "Y", TextEditBox, {Set Text( "Idleak (uA)" )} ),

  Dispatch( {}, "Overlay Plot Graph", FrameBox, {Frame Size( 740, 585 )} )

  )

)

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: How can I use JSL to create an "Overlay Plot" with data series?

A column list can be used for setting Y columns dynamically:

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

y_cols = {:height, :weight};

dt << Overlay Plot(X(:age), Y(Eval(y_cols)));

View solution in original post

10 REPLIES 10
ms
Super User (Alumni) ms
Super User (Alumni)

Re: How can I use JSL to create an "Overlay Plot" with data series?

A column list can be used for setting Y columns dynamically:

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

y_cols = {:height, :weight};

dt << Overlay Plot(X(:age), Y(Eval(y_cols)));

natalie_
Level V

Re: How can I use JSL to create an "Overlay Plot" with data series?

Thank you very much!  This is working well.

ms
Super User (Alumni) ms
Super User (Alumni)

Re: How can I use JSL to create an "Overlay Plot" with data series?

Forgot about the markers. See below for an example where the Overlay Marker command is build as a string before parsed and evaluated. May exist a simpler approach.

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

pf = [8, 26, 2, 5, 6, 17, 7, 11, 3, 18, 19, 24, 25]; //preferred marker order

y_cols = dt<<get column names(string, numeric); // List of y column names

// Create Overlay Plot

op = dt << Overlay Plot(X(:age), Y(Eval(y_cols)));

// Set markers

For(i = 1, i <= N Items(y_cols), i++,

    Eval(Parse("op<<:" || y_cols[i] || "(Overlay Marker(" || Char(pf[i]) || "))"))

);

natalie_
Level V

Re: How can I use JSL to create an "Overlay Plot" with data series?

Oh one more thing, what should I do if I don't want to include the first column?

ms
Super User (Alumni) ms
Super User (Alumni)

Re: How can I use JSL to create an "Overlay Plot" with data series?

What do you mean? The X-column? Or the first column of the table?

natalie_
Level V

Re: How can I use JSL to create an "Overlay Plot" with data series?

My first column in my table contains my x-values.  I just don't want to include it as a y-column in the code.

Thanks

ms
Super User (Alumni) ms
Super User (Alumni)

Re: How can I use JSL to create an "Overlay Plot" with data series?

I see. If you use the quick way to get a list of all numeric columns as in my second example, the first column must be removed.

An alternative is to build the list in a For-loop and include only the columns you need.

To remove the first item from a list:

Remove From(y_cols, 1);

If the x column is always the first but its name may change it can be useful to keep it in the list as in the example below. Note how I use indices to specify the columns that go into the X and Y roles, respectively.

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

pf = [8, 26, 2, 5, 6, 17, 7, 11, 3, 18, 19, 24, 25]; //preferred marker order

cols = dt << get column names(string, numeric); // List of column names; x first

n = N Items(cols);

// Create Overlay Plot

op = dt << Overlay Plot(X(cols[1]), Y(cols[2 :: n]));

// Set markers

For(i = 2, i <= n, i++,

    Eval(Parse("op<<:" || cols[i] || "(Overlay Marker(" || Char(pf[i]) || "))"))

);

natalie_
Level V

Re: How can I use JSL to create an "Overlay Plot" with data series?

Thank you, this makes a lot of sense actually.  I like the ​N ​Items​ function, too.  I think that can come in handy for sure.

natalie_
Level V

Re: How can I use JSL to create an "Overlay Plot" with data series?

Hi again,

I have a syntax question.  How can I remove multiple columns from a list?

I tried this Remove From(y_cols, 1::57), but it is not working.

Thanks!