My data table has got part_ID entries in column 1. In column 2, the 5 summary parameters - Min, Q1, Median Q3, Max and the test limits LSL, USL appear. In column 1 the part ID is repeated 7 times (corresponding to 5 summary parameters + LSL & USL, total 7) after which the next part ID appears (and corresponding 7 numbers in column 2).
I do not want to change the format of the data table (i.e. do not want to transpose).
I want to create box plot trend chart (with part ID on X-axis) using the 5 summary parameters and the limits. How to do this via JSL?
@jthi Thanks for your suggestions on this topic which I am returning to as I have to keep the data format as in my example data attached in this thread earlier. I can get almost what I need with the script below (there could be better ways to do this but below is my tale). I need help with two things.
Names Default To Here (1);
clear log ();
dt = Current Data Table ();
//Set LSL/USL marker and color
dt << Row Selection(
Select where( Contains( :Label, "LSL" ) | Contains( :Label, "USL" ) ),
Match case( 1 ),
Dialog( Edit( Contains( Source Column( :Label ) ) ) )
) << Markers( 29 ) << Colors( "Red" );
dt << Clear Select;
// Set Q1/Q3 marker and color
dt << Row Selection(
Select where( Contains( :Label, "Q1" ) | Contains( :Label, "Q3" ) ),
Match case( 1 ),
Dialog( Edit( Contains( Source Column( :Label ) ) ) )
) << Markers( 29 ) << Colors( "Black" );
dt << Clear Select;
//Set Median arker and color
dt << Row Selection(
Select where( Contains( :Label, "Median" ) ),Match case( 1 ),
Dialog( Edit( Contains( Source Column( :Label ) ) ) )
) << Markers( 0) << Colors( "Blue" );
dt << Clear Select;
// Plot chart
gb = Graph Builder(
Size( 404, 412),
Show Control Panel( 0 ),
Variables( X( :partID ), Y( :Resistance ), Y( :Current ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 37 ), Jitter( "None" ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 35 ), Jitter( "None" ) ) ),
Local Data Filter(
Add Filter(
columns( :Label ),
Where( :Label == {"LSL", "Median", "Q1", "Q3", "USL"} )
)
),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
37,
Properties( 0, {Line Color( 0 )}, Item ID( "Resistance", 1 ) )
), Legend Model(
35,
Properties( 0, {Line Color( 0 )}, Item ID( "Current", 1 ) )
)}
)
)
);
This additional script called by the earlier script (in this thread) does what I wanted. Script is specific to my data but shows a way to plot V Line () within a loop across different Frameboxes.
Changing to BoxPlots on the Graphbuilder with Q1, Q2 and Median selected in the local data filter gets proper boxplots. V line () connects the Max and Min completing the anatomy of a box plot. As only Q1, Q2 are selected and rest of the data ignored, I think one gets the correct box (selecting more parameters such as Min and Max in the local data filter gives incorrect box).
Names Default To Here (1);
Clear Log ();
setVLines_atMinMax = Function ( {gbr, FrameboxNo, PartNo, Min, Max}, {},
Eval(EvalExpr(gbr [Framebox (FrameboxNo)]<< Add graphics Script (
V Line (Expr(PartNo-1), Expr(Min), Expr(Max));
)));
);
gbr = gb << report;
nParts =5;
nc = ncols (dt); //number of coulms in my data table
For (j =1, j <=(nc-1), j++,
FrameboxNo = j;
for ( i = 1, i <= nParts, i++,
ind = (7*i-3); //show (ind);
ind_next = (7*i -3) + 1; //show (ind_next);
PartNo = Num(:PartID[ind]); //show (PartNo);
Min = Column(nc) [ind]; show (Min);
Max = Column(nc) [ind_next]; show (Max);
setVLines_atMinMax (gbr, FrameboxNo, PartNo, Min, Max);
);
nc = nc-1;
);
//show (FrameboxNo); show (nc);
Is there some specific reason of not changing the data format to something better?
From
to something easier to manage
If you don't have any indicator which row is which, are you sure they are always in the same order?
@jthi Thanks. My original data is in the form of your bottom table but additionally with measured parameter name as an additional column. In this form I know how to do the box plots using the 7 parameters.
I use JMPs Summary () function to get my data in the form of your top table.
I need this form to plot other charts in the format I want where the measured parameter data (e.g. your column 3 in the top table) in a column. There are multiple measured parameters for the same part with different ranges (appearing in separate columns) which I plot on the Y-axis and only having the data for different measured parameters in columns allows me to have the different Y-axis scale for them in JMP (with part ID on X-axis). Different measured parameter are correlated and such a plot helps understanding the relative trends.
Hope above explains why my data is in a format of your top table.
This post might give some ideas Creating a boxplot from already summarized values.
@jthi . Thanks. I have looked at the recipe in your link. The described method only seem to work when the data is the format of your second table, which is not what I want.
If it is possible to tell JMP to create box plots using Min, Q1, Median, Q3, Max given in an adjacent column (Label in attached example data set) for a given part ID (column 1 in attached) instead of it JMP calculating these values itself from the distribution of the values for each part, I think I will get what I want. Is this possible to do via JSL?
You could try building the boxplot using Rect() and Line() (there is also box plot seg which might work, but you need to simulate the data or use frequencies).
@jthi Thanks, I think, the box plot seg can be used to do what I want.
From the scripting index example, It is not clear to me how one would generate the box plot for each part ID (on x axis) as in my example data (attached before)
Would I need to loop through the part ID? In which case, how to decide the frame size, scale?
It would be useful if I could get basic example using my example data.
It might be that box plot seg can only be used to create single box plot for a single frame box and it will be in the center
@jthi Thanks.
If you are forced to the data format you have, you can still add new columns to the table. You can create one column for each of the statistics to follow option one in the earlier link or add two columns (value + freq) and then follow the second option. Or build it fully customized from different parts using graphic script