Windows 11 > JMP 19 > 脚本分配连续渐变 > 将渐变范围传递给列属性时出现问题JMP社区的各位朋友,大家好!
我编写了一个简单的脚本,根据列值的 0.05 分位数为连续值列分配颜色渐变。
Names Default To Here(1);
dt = current data table ();
scol = dt << Get Selected Columns ();
For (i = 1, i <= N items (scol), i++,
column (dt, scol[i]) << Format("Fixed Dec", 12, 3);
low_mark = Col Quantile(column (dt, scol[i]), 0.05);
high_mark = Col Quantile(column (dt, scol[i]), 0.95);
if(abs(low_mark) > high_mark, bound = -low_mark, bound = high_mark);
range_list = {-bound, bound, 0};
column (dt, scol[i]) << Set Property ("Color Gradient",
{"Blue White Red", Range (Eval list (range_list)),
Color cell by value (1)})
);
虽然 JMP 可以正确分配颜色,但当我随后手动编辑渐变时,JMP 会返回错误(见下文):

因此,我需要一种方法来传递渐变范围值,而不会在后续手动编辑时触发错误。
谢谢。
最好的,
TS
自动化和脚本编写回复:Windows 11 > JMP 19 > 脚本分配连续渐变 > 将渐变范围传递给列属性时出现问题您缺少表达式求值。
Names Default To Here(1);
dt = Current Data Table();
scol = dt << Get Selected Columns("String");
For Each({colname}, scol,
Column(dt, colname) << Format("Fixed Dec", 12, 3);
low_mark = Col Quantile(Column(dt, colname), 0.05);
high_mark = Col Quantile(Column(dt, colname), 0.95);
If(Abs(low_mark) > high_mark,
bound = -low_mark,
bound = high_mark
);
range_list = Eval List({-bound, bound, 0});
Eval(EvalExpr(
Column(dt, colname) << Set Property(
"Color Gradient",
{"Blue White Red", Range(Expr(range_list)), Color cell by value(1)}
)
));
);