Subscribe Bookmark RSS Feed

How to Apply Limits from Array to a graph?

mahkulin

Occasional Contributor

Joined:

Aug 30, 2016

I have 2 files, "spec" and "Data". The data has FAI, and Points (PT). I want to run a Analysis -> Quality Process -> Variability chart and automatically apply the spec for each FAI to the charts.

On some occasions i can get the Limits array to apply using below code but it is inconsistent

If i change the limits to a static value, it would work fine.

1) I'm looking for any help the community can provide

2) If there are more elegant solution, i'm also would like to know.

Example Code Below

=====================

close all (data tables, nosave); clear symbols(); delete symbols();

// Create stacked Data Table: these are just examples, i know how to read as a file

dtDataStacked = new table ("dtDataStacked");

dtDataStacked << New Column("FAI",Character,values({"01","02","02","03","03","03"}));

dtDataStacked << New Column("PT",Character,values({"A","A","B","A","B","B"}));

dtDataStacked << New Column("Value",values({1,1,2,1,2,3}));

dtSpecStacked = new table ("dtSpecStacked");

dtSpecStacked << New Column("_FAI",Character,values({"01","02","03"}));

dtSpecStacked << New Column("_LSL",numeric,Continious,values({0,0,0}));

dtSpecStacked << New Column("_USL",numeric,Continious,values({4,4,4}));

// assign limits to stackedData

dtDataStacked << update(

with (dtSpecStacked),

Match Columns(FAI = _FAI)

);

// Making Plots

current data table (dtDataStacked);

dtDataStacked << Variability Chart(

Y( :Value ),

X( :PT ),

By( :FAI),

Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),

Connect Cell Means( 1 ),

Std Dev Chart( 0 ),

Points Jittered( 1 ),

Show Box Plots( 1 ),

SendToReport(

Dispatch(

{"Variability Chart for Value"},

"2",

ScaleBox,

{

// Add Ref Line( {0, 4}, "Solid", "Dark Green","", 1, 0.25 ) // this line works

Add Ref Line( {_lsl, _usl}, "Solid", "Dark Green","", 1, 0.25 ) /// this line does not

}

)

)

);

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Here is a slightly different version that adds the reference lines to the charts after the charts are created

//close all (data tables, nosave); clear symbols(); delete symbols();

// Create stacked Data Table: these are just examples, i know how to read as a file

dtDataStacked = new table ("dtDataStacked2");

dtDataStacked << New Column("FAI",Character,values({"01","02","02","03","03","03"}));

dtDataStacked << New Column("PT",Character,values({"A","A","B","A","B","B"}));

dtDataStacked << New Column("Value",values({1,1,2,1,2,3}));

dtSpecStacked = new table ("dtSpecStacked");

dtSpecStacked << New Column("_FAI",Character,values({"01","02","03"}));

dtSpecStacked << New Column("_LSL",numeric,Continious,values({0,0,0}));

dtSpecStacked << New Column("_USL",numeric,Continious,values({4,4,4}));

// assign limits to stackedData

dtDataStacked << update(

       with (dtSpecStacked),

       Match Columns(FAI = _FAI)

);

// Making Plots

current data table (dtDataStacked);

varch = dtDataStacked << Variability Chart(

       Y( :Value ),

       X( :PT ),

       By( :FAI),

       Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),

       Connect Cell Means( 1 ),

       Std Dev Chart( 0 ),

       Points Jittered( 1 ),

       Show Box Plots( 1 )/*,

       SendToReport(

              Dispatch(

                     {"Variability Chart for Value"},

                     "2",

                     ScaleBox,

                     {                         

                           // Add Ref Line( {0, 4}, "Solid", "Dark Green","", 1, 0.25 ) // this line works

                           Add Ref Line( {_LSL, _USL}, "Solid", "Dark Green","", 1, 0.25 ) /// this line does not

                     }

              )

       )*/

);

// Add the reference lines to each of the charts

For(i=1,i<=N Rows(dtSpecStacked),i++,

report(varch)[axisbox (1)]<<Add Ref Line( dtSpecstacked:_LSL[i], "Solid", "Dark Green","", 1 );

report(varch)[axisbox (1)]<<Add Ref Line(  dtSpecstacked:_USL[i], "Solid", "Dark Green","", 1 );

);

Jim
8 REPLIES
M_Anderson

Staff

Joined:

Nov 21, 2014

Use the process capability platform.  It has the ability to write the limits directly to the column properties as part of the workflow. 

mahkulin

Occasional Contributor

Joined:

Aug 30, 2016

kindly see notes below...

txnelson

Super User

Joined:

Jun 22, 2012

JMP has the builtin capability of displaying spec limits if the limits have been saved as column properties.  Below is a modification of your script that uses this methodology

close all (data tables, nosave); clear symbols(); delete symbols();

// Create stacked Data Table: these are just examples, i know how to read as a file

dtDataStacked = new table ("dtDataStacked2");

dtDataStacked << New Column("FAI",Character,values({"01","02","02","03","03","03"}));

dtDataStacked << New Column("PT",Character,values({"A","A","B","A","B","B"}));

dtDataStacked << New Column("Value",values({1,1,2,1,2,3}));

dtSpecStacked = new table ("dtSpecStacked");

dtSpecStacked << New Column("_FAI",Character,values({"01","02","03"}));

// Add the spec limits as column properties to your column "Value"

dtDataStacked:value << set property("Spec Limits",{LSL(0),USL(4),show limits(1)});

/*

dtSpecStacked << New Column("_LSL",numeric,Continious,values({0,0,0}));

dtSpecStacked << New Column("_USL",numeric,Continious,values({4,4,4}));

*/

// assign limits to stackedData

dtDataStacked << update(

       with (dtSpecStacked),

       Match Columns(FAI = _FAI)

);

// Making Plots

current data table (dtDataStacked);

dtDataStacked << Variability Chart(

       Y( :Value ),

       X( :PT ),

       By( :FAI),

       Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),

       Connect Cell Means( 1 ),

       Std Dev Chart( 0 ),

       Points Jittered( 1 ),

       Show Box Plots( 1 )

/*,

       SendToReport(

              Dispatch(

                     {"Variability Chart for Value"},

                     "2",

                     ScaleBox,

                     {                         

                           // Add Ref Line( {0, 4}, "Solid", "Dark Green","", 1, 0.25 ) // this line works

                           Add Ref Line( {_LSL, _USL}, "Solid", "Dark Green","", 1, 0.25 ) /// this line does not

                     }

              )

       )*/

);

Jim
mahkulin

Occasional Contributor

Joined:

Aug 30, 2016

kindly see notes below...

mahkulin

Occasional Contributor

Joined:

Aug 30, 2016

Apologies for not making the example representative of my issue.


Suppose the limits are different by FAI. and I would like to understand how each PT performs within the same FAI.


The initial "dtDataStacked" is basically the result of stacked data which originally had the FAI, PT, Value all in different columns. I recall the requirement for Variable Gauge chart is you must stack them first to hence the dtSpecStacked.


Kindly review the original Code lines to below to illustrate my issue...

dtSpecStacked << New Column("_LSL",numeric,Continious,values({0,0,0}));

dtSpecStacked << New Column("_USL",numeric,Continious,values({4,5,7}));


So

FAI = 01 has limits of 0~4

FAI = 02 has limits of 0~5

FAI = 03 has limits of 0~7

... etc


Solution

Here is a slightly different version that adds the reference lines to the charts after the charts are created

//close all (data tables, nosave); clear symbols(); delete symbols();

// Create stacked Data Table: these are just examples, i know how to read as a file

dtDataStacked = new table ("dtDataStacked2");

dtDataStacked << New Column("FAI",Character,values({"01","02","02","03","03","03"}));

dtDataStacked << New Column("PT",Character,values({"A","A","B","A","B","B"}));

dtDataStacked << New Column("Value",values({1,1,2,1,2,3}));

dtSpecStacked = new table ("dtSpecStacked");

dtSpecStacked << New Column("_FAI",Character,values({"01","02","03"}));

dtSpecStacked << New Column("_LSL",numeric,Continious,values({0,0,0}));

dtSpecStacked << New Column("_USL",numeric,Continious,values({4,4,4}));

// assign limits to stackedData

dtDataStacked << update(

       with (dtSpecStacked),

       Match Columns(FAI = _FAI)

);

// Making Plots

current data table (dtDataStacked);

varch = dtDataStacked << Variability Chart(

       Y( :Value ),

       X( :PT ),

       By( :FAI),

       Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),

       Connect Cell Means( 1 ),

       Std Dev Chart( 0 ),

       Points Jittered( 1 ),

       Show Box Plots( 1 )/*,

       SendToReport(

              Dispatch(

                     {"Variability Chart for Value"},

                     "2",

                     ScaleBox,

                     {                         

                           // Add Ref Line( {0, 4}, "Solid", "Dark Green","", 1, 0.25 ) // this line works

                           Add Ref Line( {_LSL, _USL}, "Solid", "Dark Green","", 1, 0.25 ) /// this line does not

                     }

              )

       )*/

);

// Add the reference lines to each of the charts

For(i=1,i<=N Rows(dtSpecStacked),i++,

report(varch)[axisbox (1)]<<Add Ref Line( dtSpecstacked:_LSL[i], "Solid", "Dark Green","", 1 );

report(varch)[axisbox (1)]<<Add Ref Line(  dtSpecstacked:_USL[i], "Solid", "Dark Green","", 1 );

);

Jim
txnelson

Super User

Joined:

Jun 22, 2012

I modified my last entry, to read the specs from the dtSpecstacked data table, and to just add the limits from row one to chart one, row two to chart two, etc.

Jim
mahkulin

Occasional Contributor

Joined:

Aug 30, 2016

Splendid... Works exactly as i needed on this dummy code. Nowi have to do some modification to my original code