你好,我是 jmp 脚本语言的新手。 下面的代码可以工作(它显示第 3 列到第 n 列的条形图),但我想做一件事。 我如何编写脚本以使我的输出应该是所有列的堆叠条形图?
for(i=3,i<=NItems(colList2),i++,
国标= dt4 <<图形生成器(
大小(534,454),
显示控制面板(0),
变量(
X(:标签),Y(eval(列(dt4,colList2[i]))),
),
元素(条形图(X,Y))
));
没有一个语句可以扩展以覆盖不同数量的传入 Y 列。因此,您需要采用基本形式,并根据列数动态创建它
这是基本形式
Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables(
X( :SITE ),
Y( :NPN1 ),
Y( :PNP1, Position( 1 ) ),
Y( :PNP2, Position( 1 ) ),
Y( :NPN2, Position( 1 ) ),
Y( :PNP3, Position( 1 ) )
),
Elements(
Bar(
X,
Y( 1 ),
Y( 2 ),
Y( 3 ),
Y( 4 ),
Y( 5 ),
Legend( 4 ),
Bar Style( "Stacked" )
)
)
);
这是我创建的示例脚本,用于动态构建堆积条形图
names default to here(1);
dt=open("$SAMPLE_DATA/Blood Pressure.jmp");
// Get all of the continuous data columns
colList = dt << get column names(continuous,string);
// Create the JSL to create the script
theExpr = "Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables(
X( :Dose ),";
// Add the first Y entry
theExpr = theExpr || "Y( :" || colList[1] || " )";
// Add the remaining Y entries
For( i=2, i<= n items(colList), i++,
theExpr = theExpr || ", Y( :" || colList[i] || ", Position( 1 ) )";
);
// Finish up the Variables list, and start the Elements
theExpr = theExpr || "), Elements( Bar(X, Y( 1 )";
// Add the remaining Y elements
For( i=2, i<= n items(colList), i++,
theExpr = theExpr || ", Y( " || char(i) || " )";
);
// Finish up the required specifications
theExpr = theExpr || ",
Legend( 4 ),
Bar Style( \!"Stacked\!" )
)
)
);";
// Run the created JSL
eval(parse(theExpr));
从而产生

感谢您的答复! 您是否知道我应该如何让脚本在具有不同列名称的不同数据集中自动运行脚本,而不必交互使用图形生成器?
@tx尼尔森写道:
以交互方式,转到图形生成器,并将图形开发为您想要的外观,然后只需转到红色三角形,然后选择“保存脚本”。 JMP 为您创建 JSL。