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 . The whole reason for having the data in format of your top table (and mine which is attached) is only so that I can have different scales in a group by Y plot.
I do not want to you the Page option so I went and followed @txnelson 's suggestion to put the relevant data in form he suggested i.e. in separate columns (assuming I have understood his suggestion correctly).
If there is any other way without using Page or @txnelson 's suggestion (another similar here), I am all ears :).
@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 added to above gives what is desired using V Line ().
Example only for PartID =1 (chart below). How to make this automatic in a loop?
gbr = gb << report;
// For FrameBox (1)
Q1_Part1_Para1 = 2.75;
Q3_Part1_Para1 = 3.1;
// For FrameBox (2)
Q1_Part2_Para1 = 250;
Q3_Part2_Para1 = 302;
PartNo = 1;
Eval(EvalExpr(gbr [Framebox (1)]<< Add graphics Script (
Pen color (black); V Line (PartNo-1, Q1_Part1_Para1, Q3_Part1_Para1);
)));
Eval(EvalExpr(gbr [Framebox (2)]<< Add graphics Script (
Pen color (black); V Line (PartNo-1, Q1_Part2_Para1, Q3_Part2_Para1);
)));
You can use Summarize() to get unique partID values. Then you can use datatable subscripting with combination of Loc() to get rows for for specific partID while loopping. Then calculate/get your values and add your lines
>>You can use Summarize() to get unique partID values.
OK
>>Then you can use datatable subscripting with combination of Loc() to get rows for for specific partID while looping.
Never used Loc (). Does this give me the X coordinate for each partID. An example with my example data would be vey useful.
>> Then calculate/get your values and add your lines.
Do you mean, calculate X coordinates for each part as other numbers Min, Max, Q1, Q3 and Median are already calculated?
Also, do I need to loop through each FrameBox or is there a more straightforward alternative?
Your partIDs are in same order in the graph as they are in the table (and Summarize) so you have already the x-coordinate. If you have all the values you need already calculated, you can just retrieve them from data table. Below is example using Summarize, Loc and datatable subscripting
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
Summarize(dt, uniq_vals = by(:age)); // Summarize returns characters
For Each({uniq_val}, uniq_vals,
val_rows = Loc(dt[0, "age"], Num(uniq_val));
show(val_rows);
f_rows = val_rows[Loc(dt[val_rows, "sex"], "F")];
show(f_rows);
f_heights = dt[f_rows, "height"];
show(f_heights);
);
You have only two frame boxes but multiple lines you wish to add inside those, so there should be no need to loop over FrameBoxes (loop over the partIds)
Edit:
Also instead of Loc you could use << Get Rows Where as it is usually easier to use
@jthi . OK. Thanks. I will give this a shot (will come back if I get stuck).
In my actual data set, the number of measured parameters is >50 (could be more) so if I were to plot all 50 parameter trend plots on top of each other, there will be 50 FrameBoxes, hence my question on looping over FrameBoxes.
Also, for my PartID = 1, I ad to use the X= 0, for the X coordinate in V Line () in my script above. Is this how this is supposed to be (i.e. the x coordinate for V Line starts from 0 and not 1, even though it shows 1)?
If there are that many parameters having additional loop is a good idea.
And for the X = 0 thing, I would suggest try it. See what happens (this way you usually learn the most). You can also see from X-axis settings that the value is 0 and label 1
@jthi OK. Thanks. One more thing is bothering me. I have switched off the jitter in my script, but the top (Q3) and bottom (Q1) markers are still appearing with an offset. You can run my script with the data table attached before to test this (I am on JMP 16.2).
Is there another Jitter setting I need to switch off.
The jitter/offset is more evident if I use the following to set markers for Q1 and Q3 (just trying to get the box shape before I draw the vertical line), but even with horizontal marker I see some offset. Am I missing something?
// Q1/Q3 marker and color
dt << Row Selection(Select where(Contains( :Label, "Q3" ) ),Match case( 1 ),Dialog( Edit( Contains( Source Column( :Label ) ) ) )
) << Markers( "Π" ) << Colors( "Black" );
dt << Clear Select;
dt << Row Selection(Select where( Contains( :Label, "Q1" ) ), Match case( 1 ), Dialog( Edit( Contains( Source Column( :Label ) ) ) )
) << Markers( "Џ" ) << Colors( "Black" );
dt << Clear Select;
The offset could be due to JMPs rendering of the chart, depending on the Size () set under Graph Builder (). Stretching the chart horizontally is fixes some offset on some but not all points.
checking this way
frame = (gbr)[FrameBox( 1 )];
seg = (frame << FindSeg( Marker Seg( 1 ) ));
{method, axis, limit, spacing, seed} = seg << Get Jitter();
I do get a value of "seed" even after setting Jitter to none
{"None", "XY", 1, 0, 184430754}
Are my points jittered (they do appear so)?