Insegno i grafici Outlier Box e ho scritto una sceneggiatura per aggiungere l'intera lunghezza dei baffi in modo da poter mostrare visivamente alla mia classe come vengono calcolati i baffi. Lo script funziona benissimo a meno che le mie colonne non siano bloccate. Perché il blocco delle colonne avrebbe un impatto sul mio script? Dopo l'esecuzione dello script, l'ho salvato in una finestra di script ed è corretto, ma non disegnerà i baffi su alcuni gruppi. Ecco il mio script, ci sto ancora lavorando, sto usando JMP Pro 17.0.0 su un MacBook:
Names Default To Here( 0 );
Clear Log();
dt = Current Data Table();
If( Not( Is Scriptable( dt ) ),
// Check that there is a data set open;
// ca=Caption("Please Open Design Data Set", Back Color(yellow));
// Stop();
dtsel = Pick File( "Open File", {"JMP|jmp", "All files|*"} );
If( dtsel == "",
Stop(),
Try( dt = Open( dtsel ), Stop() )
);
);
output = Expr(
dt2 = Data Table( dt ) << Summary(
Group( bycol ),
Median( nm ),
Interquartile Range( nm ),
Quantiles( 25, nm ),
Quantiles( 75, nm ),
Freq( "None" ),
Weight( "None" ),
Link to original data table( 0 )
);
columnnamemedian = Column( dt2, 3 ) << Get Name;
columnnamesample = Column( dt2, 2 ) << Get Name;
columnnamegroup = Column( dt2, 1 ) << Get Name;
columnameIQR = Column( dt2, 4 ) << Get Name;
columnname25 = Column( dt2, 5 ) << Get Name;
columnname75 = Column( dt2, 6 ) << Get Name;
Medians = Column( dt2, columnnamemedian ) << Get As Matrix;
Samplesize = Column( dt2, columnnamesample ) << Get As Matrix;
Groups = Column( dt2, columnnamegroup ) << Get As Matrix;
IQR = Column( dt2, columnameIQR ) << Get As Matrix;
Q25 = Column( dt2, columnname25 ) << Get As Matrix;
Q75 = Column( dt2, columnname75 ) << Get As Matrix;
meanno = N Rows( dt2 );
LWhis = {};
UWhis = {};
i = 1;
For( i = 1, i <= meanno, i++,
LWhis[i] = Q25[i] - 1.5 * IQR[i];
UWhis[i] = Q75[i] + 1.5 * IQR[i];
Show( Q25[i] );
Show( Q75[i] );
Show( LWhis[i] );
Show( UWhis[i] );
Show( IQR[i] );
Show( i );
If( LWhis[i] > Q25[i],
LWhis[i] = Q25[i],
LWhis[i] = LWhis[i]
);
If( UWhis[i] < Q75[i],
UWhis[i] = Q75[i],
UWhis[i] = UWhis[i]
);
);
MinLW = LWhis[1];
MaxUW = UWhis[1];
i = 1;
For( i = 1, i <= meanno, i++,
If( LWhis[i] < MinLW,
MinLW = LWhis[i],
MinLW = MinLW
);
If( UWhis[i] > MaxUW,
MaxUW = UWhis[i],
MaxUW = MaxUW
);
);
If( MinLW < 0,
MinLW = MinLW * 1.1,
MinLW = MinLW * 0.9
);
If( MaxUW < 0,
MaxUW = MaxUW * 0.9,
MaxUW = MaxUW * 1.1
);
Current Data Table( dt );
//Close(dt2, NoSave);
gb = Graph Builder(
Variables( X( (Column( bycol )) ), Y( Column( nm ) ) ),
Elements( Points( X, Y ), Box Plot( X, Y ) ),
SendToReport(
Dispatch( {} ),
),
);
gbr = gb << report;
Report( gb )[AxisBox( 2 )] << Max( MaxUW ) << Min( MinLW );
i = 1;
For( i = 1, i <= meanno, i++,
Show( LWhis[i] );
Show( UWhis[i] );
Eval(
Eval Expr(
gbr[Framebox( 1 )] << Add graphics Script(
Pen Color( Red );
Line Style( "Dotted" );
V Line( Expr( i ), Expr( LWhis[i] ), Expr( Q25[i] ) );
V Line( Expr( i ), Expr( Q75[i] ), Expr( UWhis[i] ) );
);
)
)
;
);
//dt2 << Minimize Window;
Close( dt2, Nosave );
);
w = New Window( "Variables",
<<MODAL></MODAL>