你好,
(關於上下文的注意事項:我正在開發一個圖形模板,該模板自動為數據集中的每個標籤(A、B、C、D 和 E)製作圖形(請參閱附加腳本),然後將其附加到同一個輸出窗口便於導出和共享。 在這裡,我使用標籤“A”的單個圖形作為示例來證明我的腳本有什麼問題。 )
我的 JMP 腳本出現問題,無法從模式窗口中的用戶選擇中讀取選定的 Group-by 變量。 我希望用戶從數據中選擇一個“分組依據”列名,該列名可以是任何分組變量,並具有圖例和著色方案,如下例所示。

在隨附的 JMP 數據表中,我的玩具數據具有通用的“組”列。 但是,用戶應該能夠從表中選擇任何字符變量(例如製造地點、批次、工藝、配方)並具有分組依據的圖例和配色方案。
這是我的 JMP 腳本:
//select the data in the original data table
Names Default To Here( 1 );
dt = Current Data Table();
/*
2/28/2022 Edit
get column names to
1. get x-axis variable
2. get grouping variable for coloring the dots
- needs to be a none option for when there is no group
- logic statement later if set_groupby is "none", then no
-
Also, ask user what coloring scheme should be used.
JMP auto color (blue and red) or none (if manually coloring by, for example, batch ID)
see source: https://www.jmp.com/support/help/zh-cn/15.2/index.shtml#page/jmp/get-column-names.shtml
*/
column_names = dt << Get Column Names( Numeric, character, String );
//TO DO:
//names_for_groupby_select =
//group by should be a character variable only, so
<FONT color="#FF0000">groupby_col_names = dt << Get Column names(character, String);</FONT>
nw1 = New Window("Set X-axis and group by variable",
<<MODAL>groupby_col = Radio Box(groupby_col_names),
H List Box(
Button Box("OK",
answers = Eval List({set_xlabel = xaxisselect << get selected,
<FONT color="#FF0000">set_groupby = groupby_col << get selected</FONT>
});
nw1 << close window;
),
Button Box("Cancel")),
//change popup window size
<<SIZE window=""> 9, 5);
// generic chart (can be control chart or process chart)
Oneway(
SendToByGroup( {:Name("Label (y-axis)") == label_val},
Y( :Result ),
X( char(set_xlabel) ), //:Name("x axis") ),
Connect Means( 1 ),
Grand Mean( 0 ),
SendToReport(
Dispatch(
{},
"Result",
TextEditBox,
{Set Text( label_val || units_formatted )}
),
//font size:
Dispatch(
{},
"2",
ScaleBox,
{Label Row( Set Font Size( font_size ) )}
),
//graph stuff:
Dispatch(
{},
"Oneway Plot",
FrameBox,
{Frame Size( 1000, 300 ), DispatchSeg(
CustomStreamSeg( 6 ),
{Line Color( "Gray" )}
),
<FONT color="#FF0000">Row Legend(
//group by this
//:Name("Group"), //or just Group works too
char(set_groupby), // << need to be specified by user.
//set_groupby, // TO DO: fix this bug!</FONT>
Color( 1 ),
Color Theme( "JMP default" ), // TO DO: << needs to be specified by user.
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
)
);
);
container << Append(content)
);</SIZE></MODAL>
在這個 JMP 腳本中,x 軸列選擇有效(請參見下面的模態窗口示例和結果圖),因此我假設 group-by 變量引用也將有效。 但是輸出會生成一個沒有任何分組變量或圖例的圖形。 我的代碼在這裡做錯了什麼?
模態窗口:

標籤“A”的 JMP 輸出示例圖

我通過這個帖子。
通過在 char(set_groupby) 中使用 Column(listDT,set_groupby)。
Row Legend(
//group by this
Column(listDT,set_groupby),
Color( 1 ),
Color Theme( "JMP default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}您也可以使用 Eval()
Row Legend(
//group by this
Eval(set_groupby),
Color( 1 ),
Color Theme( "JMP default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}