x 軸上的多條參考線你好,
對於我正在從事的一個項目,我創建了一個圖表,其中 x 軸上顯示了大約 24 小時的時間段。 為了直觀地說明何時是夜間和白天,我添加了參考線,如下面的腳本和附圖所示。
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);
創建圖表,添加和配置參考線:
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"]
));
但現在我有兩週的數據,我仍然想直觀地說明白天和黑夜的情況。 我當然可以手動添加這些並複制腳本,但我想以穩健的方式執行此操作。
我可以以任何方式將這些額外的屬性添加到“自第一次給藥以來的時間 - [小時]”列或者是否可以創建一個包含所有限制的單獨數據表並將它們一次性拉入數據表?
提前致謝。
朱莉弟兄

大規模定制質量和工藝工程回复:x 軸上的多條參考線我實際上在這方面得到了幫助,結果是這樣的:
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" ) ) );
);
回复:x 軸上的多條參考線這是一個非常有趣的數據集,感謝您發布它和您的問題。
如果我有無限的時間,如果黑暗階段是一條帶有一點灰色陰影的間隔線,看起來會更好。 也許其他人可以拿起它並運行它?
回复:x 軸上的多條參考線哇非常感謝您的解釋。 這很有道理,而且效果也很漂亮。
回复:x 軸上的多條參考線亮相線和暗相線未出現在預期位置的第二個問題是由於軸變量和用於定義線應去向的變量之間不匹配。
在圖表中,x 軸是持續時間,在自定義腳本中,線條基於行號,因此圖表生成器使用行號並將其繪製在持續時間上,這是行不通的。
我在數據表中添加了幾列,它們與一些原始列類似,但有一些小的調整和格式差異。
//if you have the data table open, make it the active table and run this
dt=current data table();
dt<<NEW column=""></NEW>
下一步是編輯圖表中的自定義腳本。
//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.
結果就是固定圖,像這樣。

經過所有更改,x 軸現在採用天:小時:分鐘格式,並且所有明暗相位線都顯示在正確的位置。 階段標籤被縮寫,這樣它就不會重疊,只會使混亂的文本變得混亂。
圖形腳本
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 )
)
);
)}
)}
)
)
)回复:x 軸上的多條參考線看起來效果很好,只是沒有達到預期,可能是由於異常值......

Y軸變量的列max()超過23。 因此,文本與圖形的其餘部分顯示不成比例。
回复:x 軸上的多條參考線你好@Byron_JMP
謝謝你的建議。
我嘗試使用您描述的設置,並且在一定程度上發揮了作用。 為了遵循相同的過程,我在數據表 (NewPhase) 中創建了一個新列,其中未丟失的行應生成事件行。
我僅根據行數最多的動物編號來輸出 NewPhase 列,這樣我只會獲得一組事件線,而不是每隻動物一組:
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"
),
.
)));然後我根據您的輸入創建了圖表
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 )}
)
)
);但由於某種原因,它只包含有限數量的行,並且根本不包含任何文本。
我究竟做錯了什麼?
回复:x 軸上的多條參考線我使用列來定義何時添加參考線。 我想添加範圍也同樣容易。
以下是一些可能有用的註釋:事件線和控製圖註釋