你好,我是 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。