Linee di riferimento multiple sull'asse xCIAO,
Per un progetto su cui sto lavorando ho creato un grafico con il tempo sull'asse x che mostra un periodo di circa 24 ore. Per illustrare visivamente quando è notte e giorno, ho aggiunto delle linee di riferimento come mostrato nello script sottostante e nell'immagine allegata.
Proprietà per la colonna dell'asse x:
SableData << New Column(
"Time since first dose-[hours]",
Numeric, "Continuous",
Format("Best", 12),
Formula((:Date Time - :StartTime) / (60 * 60)),
Set Property("Spec Limits", {LSL(8), USL(20), Show Limits(0)}), Set Selected);
Creazione di grafici, aggiunta e configurazione di linee di riferimento:
Oxygen consumption = SableData << Graph Builder(
Size( 1007, 689 ),
Variables(
X( :Name( "Time since first dose-[hours]" ) ),
Y( :Name("VO2-[ml/min]" )),
Overlay( :Treatment )
),
Elements( Line( X, Y, Legend( 21 ), Error Bars( "Standard Error" ) ) ),
SendToReport(
Dispatch( {}, "Graph Builder", OutlineBox, {Set Title( "Oxygen consumption" )} ),
Dispatch(
{},
"Time since first dose-[hours]",
ScaleBox,
{Min( 168 ), Max( 288), Inc( 2 ), Minor Ticks( 12 )}
),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
21,
Properties( 0, {Line Color( 0 )}, Item ID( "A", 1 ) ),
Properties(
1,
{Line Color( 53 )},
Item ID( "B", 1 )
),
Properties(
2,
{Line Color( 37 )},
Item ID( "C", 1 )
),
Properties( 3, {Line Color( 0 )}, Item ID( "A", 2 ) ),
Properties(
4,
{Line Color( 53 )},
Item ID( "B", 2 )
),
Properties(
5,
{Line Color( 37 )},
Item ID( "C", 2 )
)
)}
),
Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 0 )} ),
Dispatch( {}, "400", LegendBox, {Set Title( "" )} )
)
);
Eval(
Substitute(
Expr(
Report( Oxygen consumption )[AxisBox( 1 )] << Add Ref Line( {__LSL__, __USL__}, "Solid", "Black", "", 1, 0.25 ) //try show limits(1) in spec limits
),
Expr( __LSL__ ), (SableData:Name( "Time since first dose-[hours]" ) << get property( "spec limits" ))["LSL"],
Expr( __USL__ ), (SableData:Name( "Time since first dose-[hours]" ) << get property( "spec limits" ))["USL"]
));
Ma ora ho dati che coprono due settimane e vorrei ancora illustrare visivamente quando è notte e giorno. Ovviamente posso aggiungerli manualmente ma e copiare lo script, ma mi piacerebbe farlo in modo robusto.
Posso in qualche modo aggiungere queste proprietà extra al file "Tempo trascorso dalla prima dose-[ore]" colonna o è possibile creare una tabella di dati separata che includa tutti i limiti e inserirli nella tabella di dati in una volta sola?
Grazie in anticipo.
Fr. Julie

Personalizzazione di massaQualità e ingegneria di processoRe: Più linee di riferimento sull'asse xIn realtà ho avuto aiuto con quello e si è scoperto qualcosa del genere:
DarkLight = SableData << select where(:NewPhase == "new" ) << subset(
Output Table("DarkLight"),
columns(
:Date,
:Phase,
:Name("Time since first dose-[hours]"),
:NewPhase)
);
DarkLight:Date << data type( Character ) << Set Modeling Type( Nominal );
DarkLight << new column("Phase per day", Character, "Nominal", Formula( :Date || "-" || :Phase ) );
DarkLight << new column("High", Numeric, "Continuous", Formula(
Lag( :Name( "Time since first dose-[hours]" ), -1 ))
);
DarkLight:High << delete formula;
DarkLight << new column("Color", Character, "Nominal", set each value("Grey"));
column(DarkLight, "Time since first dose-[hours]") << Set Name("Low");
DarkLight << select where(:Phase == "Light phase") << delete rows;
RQ = SableData << Graph Builder(
Size( 938, 712 ),
Variables(
X( :Name( "Time since first dose-[hours]" ) ),
Y( :RQ ),
Overlay( :Treatment )
),
Elements( Points( X, Y, Legend( 4 ) ) )
);
x axis = Report( RQ )[AxisBox(1)];
For Each Row( DarkLight,
// draw colored regon
Eval( Eval Expr( x axis << Add Ref Line( { Expr( :Low ), Expr( :High ) }, "Solid", Expr( :Color ), , , 0.25 ) ) );
// draw border lines
Eval( Eval Expr( x axis << Add Ref Line( Expr( :Low ), "Solid", "Black" ) ) );
Eval( Eval Expr( x axis << Add Ref Line( Expr( :High ), "Solid", "Black" ) ) );
);
Re: Più linee di riferimento sull'asse xQuesto è un set di dati molto divertente, grazie per averlo pubblicato e per le tue domande.
Se avessi un tempo infinito, sarebbe ancora meglio se le fasi scure fossero una linea di intervallo ombreggiata solo un po' di grigio. Forse qualcun altro può prenderlo e correre con esso?
Re: Più linee di riferimento sull'asse xWow grazie mille per la spiegazione. Aveva senso e funziona anche magnificamente.
Re: Più linee di riferimento sull'asse xIl secondo problema con le linee di fase chiare e scure che non vengono visualizzate dove previsto è dovuto a una mancata corrispondenza tra la variabile dell'asse e la variabile utilizzata per definire dove dovrebbero andare le linee.
Nel grafico l'asse x è una durata e nello script personalizzato le righe sono basate sul numero di riga, quindi il generatore di grafici utilizza il numero di riga e lo traccia sulla durata del tempo, il che non funziona.
Ho aggiunto un paio di colonne alla tabella dei dati, sono simili ad alcune delle colonne originali, ma con alcune piccole modifiche e differenze di formattazione.
//if you have the data table open, make it the active table and run this
dt=current data table();
dt<<NEW column=""></NEW>
Il passaggio successivo consiste nel modificare lo script personalizzato nel grafico.
//This script goes into the Custom Script in the graph builder plot
For Each Row( If( Is Missing( :NewPhase ) == 0, V Line( :Time2 ) ) );
For Each Row(
If( Is Missing( :NewPhase ) == 0,
Text( {:Time2, 5 + :step2}, " "||:Phase2 )
)
);
//The, " "||:phase2, inserts a space before the label so that it isn't touching the phase line.
Il risultato è il grafico fisso, come questo.

Con tutte le modifiche, l'asse x è ora nel formato Giorni:Ore:minuti e tutte le linee di fase chiare e scure vengono visualizzate nel posto giusto. L'etichetta di fase è abbreviata in modo che non si sovrapponga e crei solo un miscuglio di testo disordinato.
Scritta grafica
Graph Builder(
Size( 1455, 290 ),
Show Control Panel( 0 ),
Variables( X( :Time2 ), Y( :Name( "EE-[kcal/h]" ) ), Overlay( :Treatment ) ),
Elements( Line( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"Time2",
ScaleBox,
{Min( -586333.5 ), Max( 2531060.48337292 ), Interval( "Day" ), Inc( 1 ),
Minor Ticks( 6 ), Label Row( Label Orientation( "Perpendicular" ) )}
),
Dispatch(
{},
"EE-[kcal/h]",
ScaleBox,
{Format( "Best", 12 ), Min( 1.7751677852349 ), Max( 5.7751677852349 ),
Inc( 1 ), Minor Ticks( 0 )}
),
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script(
2,
Description( "Script" ),
For Each Row( If( Is Missing( :NewPhase ) == 0, V Line( :Time2 ) ) );
For Each Row(
If( Is Missing( :NewPhase ) == 0,
Text( {:Time2, 5 + :step2}, " " || :Phase2 )
)
);
), Grid Line Order( 1 ), Reference Line Order( 3 ),
DispatchSeg(
TopSeg( 1 ),
{Set Script(
For Each Row(
If( Is Missing( :NewPhase ) == 0,
V Line( :Time2 )
)
);
For Each Row(
If( Is Missing( :NewPhase ) == 0,
Text( {:Time2, 5 + :step2}, " " || :Phase2 )
)
);
)}
)}
)
)
)Re: Più linee di riferimento sull'asse xsembra che funzioni bene, ma non come previsto, forse a causa di un valore anomalo...

la colonna max() della variabile dell'asse Y è superiore a 23. Quindi il testo si presenta fuori scala rispetto al resto della figura.
Re: Più linee di riferimento sull'asse xCIAO @Byron_JMP
Grazie per il suggerimento.
Ho provato a utilizzare la configurazione che descrivi e ha funzionato in una certa misura. Per seguire lo stesso processo ho creato una nuova colonna nella mia tabella dati (NewPhase) in cui le righe che non mancano dovrebbero risultare in una riga di eventi.
Ho basato l'output della colonna NewPhase esclusivamente sul numero di animali con il numero più alto di righe in modo da ottenere solo una serie di righe di eventi anziché una per ogni animale:
DataPointsAnimal = SableData << Summary(
Group( :Animal No. ),
N( :Phase ),
Freq( "None" ),
Weight( "None" ));
DataPointsAnimalSorted = DataPointsAnimal << Sort( By( :N Rows ), Order( Descending ) );
Close( DataPointsAnimal, No Save );
AnimalVar = DataPointsAnimalSorted:Animal No.[1];
SableData << New column("NewPhase", Formula(If( :Animal No. == AnimalVar,
If( :Phase == Lag( :Phase, 1 ),
.,
"new"
),
.
)));Ho quindi creato il grafico con il tuo input
Graph Builder(
Size( 924, 695 ),
Variables(
X( :Name( "Time since first dose-[hours]" ) ),
Y( :Name( "EE-[kcal/h]" ) ),
Overlay( :Treatment )
),
Elements( Line( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script(
2,
Description( "Script" ),
For Each Row( If( Is Missing( :NewPhase ) == 0, V Line( Row() ) ) );
For Each Row(
If( Is Missing( :NewPhase ) == 0,
Text(
Right Justified,
{Row(), Col Maximum( :Name( "EE-[kcal/h]" ) ) * 1.2},
:Phase
)
)
);
), Grid Line Order( 1 ), Reference Line Order( 3 )}
)
)
);Ma per qualche motivo include solo un numero limitato di righe e non include alcun testo.
Che cosa sto facendo di sbagliato?
Re: Più linee di riferimento sull'asse xHo usato le colonne per definire quando aggiungere linee di riferimento. Suppongo che sarebbe altrettanto facile aggiungere anche intervalli.
Ecco alcune note che potrebbero essere utili: Linee di eventi e commenti sulle carte di controllo