Ciao comunità JMP,
Ho uno script che traccia i dati da una serie di colonne in una tabella raggruppate in base a una variabile (:VAR_CAT) e che aggiunge dinamicamente il testo da un'altra tabella, utilizzando il Costruttore di grafici. Anche se questo script funziona bene, ho riscontrato qualche difficoltà con il posizionamento verticale del testo aggiunto dinamicamente (vedi script di seguito).
Nello specifico ho provato diversi approcci tra cui:
- YMax = Media colonna (YCOL) + (Dev std colonna (YCOL)/sqrt(Numero colonna (YCOL))); ma questo non funziona abbastanza bene perché restituisce YMAX per l'intera colonna e non per il sottoinsieme definito dalla variabile Overlay --> quali sarebbero le righe di codice corrette per calcolare dinamicamente il massimo effettivo dell'asse Y per i dati raggruppati in Categorie sovrapposte (so che l'opzione "Per" funziona solo all'interno di una struttura Per ogni riga)?
- YMAX = rapporto (gb)[Riquadro dell'asse (2)] << Ottieni il massimo; che recupera il massimo effettivo per l'asse Y GB ma questo approccio mi costringerebbe a valutare l'espressione una seconda volta che non sembra efficiente o elegante
Names Default to Here (1);
dt1 = Data Table ("DATA_TABLE.JMP");
dt2 = Data Table ("PVALUE_TABLE.JMP");
CList = dt1 << Get Column Names(string);
gbe = Expr (Graph Builder(
Size( 497, 507 ),
Variables(
X( :DURATION ),
Y( _YS_ ),
Overlay( :VAR_CAT ),
Interval( _ES_)
),
Elements( Points( X, Y, Legend( 9 ) ), Line( X, Y, Legend( 11 ) ) ),
SendToReport(
Dispatch(
{},
_LABEL_,
ScaleBox,
{Add Ref Line( 0, "Dotted", "Black", "", 2 )}
),
Dispatch(
{},
"DURATION",
ScaleBox,
{Min( -1.0 ), Max( 16 ), Inc( 2 ), Minor Ticks( 0 )}
),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
9,
Base( 0, 0, 0, Item ID( "CAT1", 1 ) ),
Base( 1, 0, 0, Item ID( "CAT2", 1 ) )
)}
),
Dispatch(
{},
"Graph Builder",
FrameBox,
{Marker Size( 6 ), Add Graphics Script(
2,
Description( "Script" ),
Text( Center Justified, {3.8, _TP_}, _TXT1_ );
Text( Center Justified, {13.6, _TP_}, _TXT2_ );
), Grid Line Order( 1 ), Reference Line Order( 3 )}
)
)
)
);
For (i = 5, i <= 96, i++, //96
YCOL = Column (dt1, i);
ECOL = Column (dt1, i+92);
LBL = CList [i];
YMax = Col Mean (YCOL) + (Col Std Dev (YCOL)/sqrt(Col Number(YCOL)));
YMin = Col Mean (YCOL) - (Col Std Dev (YCOL)/sqrt(Col Number(YCOL)));
YRANGE = abs (YMax - Y Min);
If (YRANGE < 1.0,
YMax = YMax + 0.5;
YMin = YMin - 0.3
);
TOPY = YMax-0.1;
PVAL1 = "p VAL " || CHAR(Format(Column(dt2, 2)[i-4], "PValue"));
PVAL2 = "p VAL " || CHAR(Format(Column(dt2, 3)[i-4], "PValue"));
gbx = Substitute (Name Expr (gbe), Expr (_YS_), YCOL,
Expr (_ES_), ECOL,
Expr (_LABEL_), LBL,
Expr (_TP_), TOPY,
Expr (_TXT1_), PVAL1,
Expr (_TXT2_), PVAL2
);
gb = Eval (gbx);
Yaxis = report (gb)[Axis Box (2)];
LocYMin = Yaxis << Get Min;
LocYMax = Yaxis << Get Max;
LocRange = LocYMax - LocYMin;
mytitle = substitute (LBL, "Least Sq Mean LOG2 FC ", "");
report (gb) [OutlineBox (1)] << Set Title (mytitle);
if(abs (LocRange) < 1.0,
Yaxis << Max (LocYMax + 0.5);
Yaxis << Min (LocYMin - 0.3);
Yaxis << Inc (0.2),.);
gb << Journal;
gb << close window;
); Puoi anche chiedere direttamente alla casella dell'asse:
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( Y( :weight ), X( :height ), FitLine );
rbiv = biv << report;
axisbox = rbiv[axis box( 1 )];
axisbox << Get Max;
(Da Guida > Indice di scripting)
Puoi ottenere lo script per il riquadro dell'asse e quindi trovare gli argomenti per le impostazioni Min() e Max().
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
biv = Bivariate( Y( :weight ), X( :height ), Fit Line( {Line Color( {212, 73, 88} )} ) );
y_axis_script = Report( biv )[axis box( 1 )] << get script;
/*
y_axis_script will be a list: {Scale( "Linear" ), Format( "Fixed Dec", 12, 0 ), Min( 60 ), Max( 180 ),
Interval( "Numeric" ), Inc( 20 ), Minor Ticks( 0 ), Label Row Nesting( 1 ),
Label Row(
{Automatic Font Size( 0 ), Automatic Tick Marks( 0 ), Inside Ticks( 0 ),
Label Alignment( "Near" ), Label Buffer Scale( 1 ),
Label Orientation( "Horizontal" ), Lax Label Range( 0 ),
Major Grid Line Color( -14145495 ), Minimum Depth( 0 ), Minimum Font Size( 8 ),
Minor Grid Line Color( -15790320 ), Show Major Grid( 0 ), Show Major Labels( 1 ),
Show Major Ticks( 1 ), Show Minor Grid( 0 ), Show Minor Labels( 0 ),
Show Minor Ticks( 1 ), Tick Offset( 0 ), Wrap Lines( 0 )}
)}
*/
//get the arguments for the 3rd and 4th elements of that list
minimum = Arg( y_axis_script[3], 1 );
maximum = Arg( y_axis_script[4], 1 );
Prova ad aggiungere uno di questi all'elenco degli elementi del generatore di grafici:
Casella didascalia (Y, Legenda (4), Statistica riepilogativa ("Max"))
COSÌ:
gbe = Expr (Graph Builder(
Size( 497, 507 ),
Variables(
X( :DURATION ),
Y( _YS_ ),
Overlay( :VAR_CAT ),
Interval( _ES_)
),
Elements(
Points( X, Y, Legend( 9 ) ),
Line( X, Y, Legend( 11),
Caption Box( Y, Legend( 4 ), Summary Statistic( "Max" ) )<BR /> ) ),<BR />//the rest of your codePuoi farlo visivamente facendo clic con il pulsante destro del mouse nel Costruttore di grafici e aggiungendo una casella di didascalia. Quindi nell'elenco a sinistra modifica le statistiche riassuntive in base a ciò che ti serve e modifica le variabili utilizzate per il calcolo.