Subscribe Bookmark RSS Feed

column names in lists

arnow

Community Trekker

Joined:

Feb 6, 2012

Hello,

I'm quite unfamiliar with JMP scripting and have the following problem: In a production environment, there are several process steps and for each process step there several tools. At the end measurements are performed and i need to create tool-trends for theses measurements where the measurements is on the y-axis, the date is on the x-axis and the data are group by the tool used for the lots. In order not to repeat essentially the same code several times i try the follwing for a particular measurement:

First, i create a tool-list und a date list:

tool_list=list("Tool1", "Tool2", "Tool3");

date_list=list("Date1", "Date2", "Date3");

Next, i use for to loop through the lists:

for(i=1, i<= nitems(tool_list), i++, ...)

Now, the items in each list are column names in the data table and i need to assign these to the graph builder platform. I tried something like this:

Variables(X(date_list(i)), Y(measurement1), Group Y(tool_list(i))

However, JMP does not recognize, that date_list(i) is a column name. Is there a way to specify that?

Thanks for any help!

Regards

Arno

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

You need to use square brackets instead of parentheses for referencing list elements.  Here's an example:

dt = open("$sample_data\Car Physical Data.jmp");

xlist = {"Gas Tank Size", "Weight"};

ylist = {"Displacement", "Horsepower"};

glist = {"Type", "Country"};

for (i = 1, i <= nitems(xlist), i++,

    print(i);

   

    Graph Builder(

        Show Control Panel( 0 ),

        Variables( X( column(dt, xlist[i]) ),

                Y( column(dt, ylist[i]) ),

                Color( column(dt, glist[i]) ) ),

        Elements( Points( X, Y, Color, Legend( 2 ) ) ),

        SendToReport( Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 3 )} ) )

    );

);

3 REPLIES
Solution

You need to use square brackets instead of parentheses for referencing list elements.  Here's an example:

dt = open("$sample_data\Car Physical Data.jmp");

xlist = {"Gas Tank Size", "Weight"};

ylist = {"Displacement", "Horsepower"};

glist = {"Type", "Country"};

for (i = 1, i <= nitems(xlist), i++,

    print(i);

   

    Graph Builder(

        Show Control Panel( 0 ),

        Variables( X( column(dt, xlist[i]) ),

                Y( column(dt, ylist[i]) ),

                Color( column(dt, glist[i]) ) ),

        Elements( Points( X, Y, Color, Legend( 2 ) ) ),

        SendToReport( Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 3 )} ) )

    );

);

arnow

Community Trekker

Joined:

Feb 6, 2012

Ok, here is the repost:

Thanks, it works now. But another problem came up: I need to configure the axes. The code, that formerly worked is:

prec = New Window( "Shunts vs PREC",

      dt << Graph Builder(

            Size( 853, 558 ),

            Show Control Panel( 0 ),

            Show Legend( 0 ),

            Lock Scales( 1 ),

            Variables( X( :Precursor, Size( 120 ) ), Y( :Shunts ), Group Y( :Anlage2 ) ),

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

            SendToReport(

                  Dispatch(

                        {},

                        "Precursor",

                        ScaleBox,

                        {Min( start_datum - tag ), Max( end_datum ), Interval( "Day" ), Inc( date_inc ), Minor Ticks( 0 ),

                        Rotated Labels( 1 )}

                  ),

                  Dispatch(

                        {},

                        "Shunts",

                        ScaleBox,

                        {Format( "Best", 12 ), Min( -0.1 ), Max( 12 ), Inc( 1 ), Minor Ticks( 1 ),

                        Add Ref Line( 4, Solid, {255, 0, 0} ), Show Major Grid( 1 ), Rotated Labels( "Automatic" )}

                  )

            )

      )

);

I just copied this code from the "copy script" option of the graph. Unfortunately I hardly understand the code. The updated version using lists does not do anything with the axes:

date_list = List( "Precursor", "CIS" );

tool_list = List( "Anlage2", "Anlage3" );

prec = New Window( "Shunts vs PREC",

      dt << Graph Builder(

            Size( 853, 558 ),

            Show Control Panel( 0 ),

            Show Legend( 0 ),

            Lock Scales( 1 ),

            Variables(

                  X( Column( dt, date_list[i] ), Size( 120 ) ),

                  Y( :Shunts ),

                  Group Y( Column( dt, tool_list[i] ) ),

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

                  SendToReport(

                        Dispatch(

                              {},

                              date_list[i],

                              ScaleBox,

                              {Min( start_datum - tag ), Max( end_datum ), Interval( "Day" ), Inc( date_inc ), Minor Ticks( 0 ),

                              Rotated Labels( 1 )}

                        ),

                        Dispatch(

                              {},

                              "Shunts",

                              ScaleBox,

                              {Format( "Best", 12 ), Min( -0.1 ), Max( 12 ), Inc( 1 ), Minor Ticks( 1 ),

                              Add Ref Line( 4, Solid, {255, 0, 0} ), Show Major Grid( 1 ), Rotated Labels( "Automatic" )}

                        )

                  )

            )

      )

);

Thanks and regards Arno

pmroz

Super User

Joined:

Jun 23, 2011

ArnoW,

I'm having trouble understanding your code.  Perhaps you could repost it with some formatting?

Right click on the code in a JMP script window and select Reformat Script.

Then copy/paste the code from JMP into a blank Word document.  Recopy it from Word and paste it into a reply window in this forum.  That's how I was able to post the formatted code.

Regards,

Peter