大家好
我正在使用图表生成器在报告中制作图表。 我喜欢在图表上添加参考线作为 CL、LCL、UCL。 我将它们放在表格的列(例如 X)中。 我试图在脚本中调用它们,例如,
{添加参考线(:X, "Solid", "Black", "LCL", 1 )}
但它不起作用
请你帮助我好吗
谢谢
ColMin 和 ColMax 只会从列中获取最小值或最大值并忽略缺失值。
一些简单的例子:
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(5),
New Column("Value", Numeric, "Continuous", Format("Best", 12), Set Values([., 1, ., ., 2]))
);
Show(ColMin(:Value));
Show(ColMax(:Value));
//A bit more complicated. Loc gets rows which have non missing value as a matrix
//Then we use that matrix to get values from Value column
//and finally from that we will use only the first index
Show(:Value[Loc(:Value << get as matrix)][1]);
//You can run this in parts to see how it works
//Loc(:Value << get as matrix)
//:Value[Loc(:Value << get as matrix)]
//Will return missing value
Show(:Value[1]);谢谢。它起作用了,尽管我仍然不知道列中是否缺少一些数据,以及如何选择包含数据的单元格。 但在这种情况下,使用这些功能是可行的。

您能否提供某种示例数据表? 它没有任何真实的数据,只要它显示了数据的基本思想。 根据数据的外观,您可能会使用像 ColMin(dt:UCL) 这样的 ColMin/ColMax 函数。
@jthi , 谢谢。
我将控制限作为列。 我可以将一个单元格称为 UCL[1],但问题是,其中一些列具有可能是第一个或任何其他单元格的空单元格。 我想从非空列的单元格中添加 Ref 行。
你知道我该怎么做吗?
谢谢
根据您的数据,您可以这样做:
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
//add limit columns
dt << New Column("UCL", Numeric, Continuous, Set Each Value(70));
dt << New Column("CL", Numeric, Continuous, Set Each Value(60));
dt << New Column("LCL", Numeric, Continuous, Set Each Value(50));
gb = Graph Builder(Variables(X(:age), Y(:height)), Elements(Points(X, Y, Legend(4))));
axisb = (report(gb)[axisbox(2)]);
axisb << ({
Add Ref Line(dt:UCL[1], "Solid", "Black", "UCL", 1),
Add Ref Line(dt:CL[1], "Solid", "Black", "CL", 1),
Add Ref Line(dt:LCL[1], "Solid", "Black", "LCL", 1)
});或者直接绘制这些列:

或将它们设置为列属性作为规格限制:


如果需要,所有这些都可以编写脚本。
编辑:
而且,如果您的意思是设置了 Control Limit Column 属性,则需要一些额外的脚本才能从列属性中获取限制(解析部分在很大程度上取决于大小写以及控制限制的设置方式,但想法应该相同):
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Quality Control/Coating.jmp");
obj = dt << Control Chart(Sample Size(:Sample), KSigma(3), Chart Col(:Weight, XBar, R));
Wait(0);
obj << Save Limits(in Column);
gb = Graph Builder(
Variables(X(:Sample), Y(:Weight)),
Elements(Points(X, Y, Legend(3)), Smoother(X, Y, Legend(4)))
);
//get Control Limits column property and parse limits
colProp = dt:weight << Get Property("Control Limits");
xbarLimits = Words(Char(colProp[1]));
xbarCL = Num(Word(3, xbarLimits[1], "()"));
xbarLCL = Num(Word(2, xbarLimits[2], "()"));
xbarUCL = Num(Word(2, xbarLimits[3], "()"));
//add control limits
axisb = (report(gb)[axisbox(2)]);
axisb << ({
Add Ref Line(xbarUCL, "Solid", "Black", "UCL", 1),
Add Ref Line(xbarCL, "Solid", "Black", "CL", 1),
Add Ref Line(xbarLCL, "Solid", "Black", "LCL", 1)
});