cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
natalie_
Level V

Saving Plots in JSL

Hi again,

I have a question about saving plots in my JSL script.  I have written some code which joins two data tables.  There are a few plots I want to make for each merged data table.  I figured out how to write the code to create one of the plots I made.

Is the best way to save the plot by saving the script to the data table?  I am not sure how to do it.  I saw in another post that someone recommended using New Table Script.

//IdVg Plot

plot=Overlay Plot(

  X(:Name("Vg (V)")), Y( :Name("Id(A/mm)"), :Name("gm (mS/mm)")),

  Y Scale (Left,Right),

  );

dt << New Table Script("IdVg", plot);

It would be even better if the plots would open with the data table when I open it later, but I am not sure if it's possible.

Thanks, Natalie

1 ACCEPTED SOLUTION

Accepted Solutions
David_Burnham
Super User (Alumni)

Re: Saving Plots in JSL

There are different ways of doing things in JMP so I'm not going to comment on "best" ways.  But JMP has the ability to easily save scripts to tables.  These scripts allow you to re-generate an analysis that you have performed with a specific platform.  So if I have a table and make create an overlay plot, then rather than save the overlay plot (as a file) I can instead simply save the script to the data table.  Then I can rerun the script to regenerate the graph.

In your example you have a script to generate a table (via concatenation etc) so it can often be convenient to use that script to append a script to the table which you do using the New Script (or New Table Script or Table Property - same thing, they are synonyms).

BUT - the 2nd argument needs to be the script itself, not a variable referring to the script.  In your example a table script will be created that contains the single word "plot" whereas you want to entire specification for the overlay plot.

dt << New Table Script( "IdVg",

    Overlay Plot(

        X(:Name("Vg (V)")), Y( :Name("Id(A/mm)"), :Name("gm (mS/mm)")),

        Y Scale (Left,Right),

    )

);

Here's an example:

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

// create some sort of derived table

someRows = dt1 << Get Rows Where(:sex=="F");

dtNew = dt1 << Subset(Rows(someRows));

// then append a script to it

dtNew << New Script( "My New Script",

    Overlay Plot(

        X( :Runtime ),

        Y( :Oxy ),

        Separate Axes( 1 )

    )

);


If you name the script "OnOpen" then the script will automatically run when the table is opened.

-Dave

View solution in original post

2 REPLIES 2
David_Burnham
Super User (Alumni)

Re: Saving Plots in JSL

There are different ways of doing things in JMP so I'm not going to comment on "best" ways.  But JMP has the ability to easily save scripts to tables.  These scripts allow you to re-generate an analysis that you have performed with a specific platform.  So if I have a table and make create an overlay plot, then rather than save the overlay plot (as a file) I can instead simply save the script to the data table.  Then I can rerun the script to regenerate the graph.

In your example you have a script to generate a table (via concatenation etc) so it can often be convenient to use that script to append a script to the table which you do using the New Script (or New Table Script or Table Property - same thing, they are synonyms).

BUT - the 2nd argument needs to be the script itself, not a variable referring to the script.  In your example a table script will be created that contains the single word "plot" whereas you want to entire specification for the overlay plot.

dt << New Table Script( "IdVg",

    Overlay Plot(

        X(:Name("Vg (V)")), Y( :Name("Id(A/mm)"), :Name("gm (mS/mm)")),

        Y Scale (Left,Right),

    )

);

Here's an example:

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

// create some sort of derived table

someRows = dt1 << Get Rows Where(:sex=="F");

dtNew = dt1 << Subset(Rows(someRows));

// then append a script to it

dtNew << New Script( "My New Script",

    Overlay Plot(

        X( :Runtime ),

        Y( :Oxy ),

        Separate Axes( 1 )

    )

);


If you name the script "OnOpen" then the script will automatically run when the table is opened.

-Dave
natalie_
Level V

Re: Saving Plots in JSL

Thank you so much!  It is working