cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to create Box Plots when 5 summary parameters (Min, Q1, Median Q3, Max) and Limits (LSL, USL) are in a column corresponding to a given part_ID?

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?

When it's too good to be true, it's neither
2 ACCEPTED SOLUTIONS

Accepted Solutions
Neo
Neo
Level VI

Re: How to create Box Plots when 5 summary parameters (Min, Q1, Median Q3, Max) and Limits (LSL, USL) are in a column corresponding to a given part_ID?

@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.

  1. I need to draw a vertical black line connecting Min and Max for each partID (currently not selected in the local data filter, left chart below). When Min/Max is selected in the local data filter (right chart below), they get connected by a vertical black line (in place of black dots now on right chart), I will get to almost the anatomy of a box plot, which I think is enough and fit for purpose. How to get this vertical line via JSL for each part ID (V Line ()?)?
  2. Secondly, my measured parameters (Current, Resistance in the example data) in actual data will be >40. So, I do not want to do the Legend color setting the way I have done in my script. How to set the legend color as black by default (otherwise JMP colors each Y-group differently and not how I have set the marker colors).

 

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 ) ) )} ) ) );

Neo_1-1697716325936.png Neo_2-1697716355004.png

 

 

When it's too good to be true, it's neither

View solution in original post

Neo
Neo
Level VI

Re: How to create Box Plots when 5 summary parameters (Min, Q1, Median Q3, Max) and Limits (LSL, USL) are in a column corresponding to a given part_ID?

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);

 

Neo_2-1698149973903.png

 

 

When it's too good to be true, it's neither

View solution in original post

21 REPLIES 21
jthi
Super User

Re: How to create Box Plots when 5 summary parameters (Min, Q1, Median Q3, Max) and Limits (LSL, USL) are in a column corresponding to a given part_ID?

Is there some specific reason of not changing the data format to something better?

From

jthi_0-1696436031094.png

to something easier to manage

jthi_1-1696436047304.png

If you don't have any indicator which row is which, are you sure they are always in the same order?

-Jarmo
Neo
Neo
Level VI

Re: How to create Box Plots when 5 summary parameters (Min, Q1, Median Q3, Max) and Limits (LSL, USL) are in a column corresponding to a given part_ID?

@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. 

 

When it's too good to be true, it's neither
jthi
Super User

Re: How to create Box Plots when 5 summary parameters (Min, Q1, Median Q3, Max) and Limits (LSL, USL) are in a column corresponding to a given part_ID?

This post might give some ideas Creating a boxplot from already summarized values

-Jarmo
Neo
Neo
Level VI

Re: How to create Box Plots when 5 summary parameters (Min, Q1, Median Q3, Max) and Limits (LSL, USL) are in a column corresponding to a given part_ID?

@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?

When it's too good to be true, it's neither
jthi
Super User

Re: How to create Box Plots when 5 summary parameters (Min, Q1, Median Q3, Max) and Limits (LSL, USL) are in a column corresponding to a given part_ID?

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).

-Jarmo
Neo
Neo
Level VI

Re: How to create Box Plots when 5 summary parameters (Min, Q1, Median Q3, Max) and Limits (LSL, USL) are in a column corresponding to a given part_ID?

@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. 

Neo_0-1696584512315.png

 

When it's too good to be true, it's neither
jthi
Super User

Re: How to create Box Plots when 5 summary parameters (Min, Q1, Median Q3, Max) and Limits (LSL, USL) are in a column corresponding to a given part_ID?

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

-Jarmo
Neo
Neo
Level VI

Re: How to create Box Plots when 5 summary parameters (Min, Q1, Median Q3, Max) and Limits (LSL, USL) are in a column corresponding to a given part_ID?

@jthi Thanks.

When it's too good to be true, it's neither
jthi
Super User

Re: How to create Box Plots when 5 summary parameters (Min, Q1, Median Q3, Max) and Limits (LSL, USL) are in a column corresponding to a given part_ID?

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

-Jarmo