你好,
我正在制作变异性图表,其中有按子组绘制的连续数据。我有 3 个温度数据带“1C 至 13C”、“16C 至 28C”和“30C 至 45C”。我想为我在数据中选择的每个过滤器类别绘制参考线,有 3 个不同的参考线组。
请参阅附件和可变性脚本。
我对脚本编写还比较陌生。我已经了解了 JMP 脚本命令如何允许您为每个参考线编写命令。我想根据数据过滤器选择的内容使命令动态化。(脚本中粗体下划线部分。
请指教,
谢谢
马特
New Window( "Sample set 1 - Variability Chart by Lot",
V List Box(
Variability Chart(
Y( :Test 1 ),
X( :Lot ),
Std Dev Chart( 0 ),
Local Data Filter( Add Filter( columns( :Temp Band 2 ) ) ),
SendToReport(
Dispatch(
{"Variability Chart for Test 1"},
"2",
ScaleBox,
{Min( 0.814090277777778 ), Max( 1.13166666666667 ), Inc( 0.05 ),
Minor Ticks( 1 ), Add Ref Line(
0, "Dotted", "Medium Light Gray", "", 1
), Add Ref Line( <U><STRONG>1.1</STRONG></U>, "Solid", "Black", "", 1 ),
Add Ref Line(<U> <STRONG>0.9</STRONG></U>, "Solid", "Black", "", 1 )}
)
)
),
Variability Chart(
Y( :Test 2 ),
X( :Lot ),
Std Dev Chart( 0 ),
Local Data Filter( Add Filter( columns( :Temp Band 2 ) ) )
),
Variability Chart(
Y( :Test3 ),
X( :Lot ),
Std Dev Chart( 0 ),
Local Data Filter( Add Filter( columns( :Temp Band 2 ) ) )
)
)
)
你好@mcastner ,我会说你选择了一个相当复杂的任务来开始编写脚本!下面是一种执行您所要求的方法(如果我对您的解释正确),但我想知道您是否可以通过使用图形生成器同时绘制箱形图和线条来简化此操作。您如何得出参考线的值?是否有可能是可用数据(中位数、分位数等)的摘要,或者您可以在公式列中这样做吗?
Names default to here(1);
dt = Open( "$Sample_data/big class.jmp" );
//Valeus for ref lines - hopefully populated by your script
reflines = Associative Array({
{"height",
Associative Array({
{ 12, 62 },
{ 13, 63 },
{ 14, 64 },
{ 15, 65 },
{ 16, 66 },
{ 17, 67 }
})
},
{"weight",
Associative Array({
{ 12, 112 },
{ 13, 113 },
{ 14, 114 },
{ 15, 115 },
{ 16, 116 },
{ 17, 117 }
})
}
});
//A window with a single data filter that will be applied to all graphs inside it
New Window("charts",
Data Filter Context Box(
H List Box(
ldf = dt << Data Filter( Local,
Add Filter(
columns( :age ),
Where( :age == 13 ),
Display( :age, N Items( 6 ) )
),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) )
),
vc1 = Variability Chart(
Y( :height ),
X( :sex )
);
vc2 = Variability Chart(
Y( :weight ),
X( :sex )
);
)
)
);
//Function that is called when data filter changes and when the window is first opened, this will redraw lines on charts
UpdateRefLines = function({},
//find out what ages were selected, there is probably a better way to do this too
filteredagelast = filteredage;
filteredage = median(dt:age[ldf << get filtered rows()]);
//detect if there was a change in the age (prevents flickering of the screen)
if(is missing(filteredagelast) | (filteredagelast != filteredage),
//remove any existing ref lines
(vc1 << XPath("//AxisBox[@charID=2]"))[1] << Revert Axis;
(vc2 << XPath("//AxisBox[@charID=2]"))[1] << Revert Axis;
//draw new lines
(vc1 << XPath("//ScaleBox[@ID=2]")) << Add Ref Line( reflines["height"][FilteredAge], "Solid", "Black", "", 1 );
(vc2 << XPath("//ScaleBox[@ID=2]")) << Add Ref Line( reflines["weight"][FilteredAge], "Solid", "Black", "", 1 );
)
);
//function called when data filter changes, here it only redraws reference lines
UpdatesOnRowStateChanges = function({x}, if(is matrix(x), UpdateRefLines ) );
//variable used to keep track of the last filter applied
filteredage = .;
//Assign function to data filter
rsh = vc1 << Make Row State Handler( dt, UpdatesOnRowStateChanges );
//draw initial reference lines
UpdateRefLines();
