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 轴上的多条参考线我使用列来定义何时添加参考线。 我想添加范围也同样容易。
以下是一些可能有用的注释:事件线和控制图注释