如何從 JSL 中的列表傳遞 Graph Builder 中的 Y 變數?下面的範例腳本滿足了我想要在 Y 軸上繪製的固定少量參數的需求。
如何自動執行上面提供給 Y 的清單?
(X 變數/列保持固定,但進入 Y 的元素數量可以更改,並由另一個腳本提供)
Names Default To Here (1);
Clear Log ();
dt = open("$sample_data\Big Class.jmp");
y_values = {"name", "age", "sex", "weight"};
Graph Builder(
Show Control Panel( 0 ),
Variables( X( :height),
Y( column(dt, y_values[1]) ),
Y( column(dt, y_values[2]) ),
Y( column(dt, y_values[3]) ),
Y( column(dt, y_values[4]) )
),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 1 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 2 ) ) ),
Elements( Position( 1, 3 ), Points( X, Y, Legend( 3 ) ) ),
Elements( Position( 1, 4 ), Points( X, Y, Legend( 4 ) ) )
);另外,在這種情況下如何處理 Elements()。
自動化和腳本編寫視窗回覆:如何從 JSL 中的列表傳遞 Graph Builder 中的 Y 變數?@hogi謝謝,恐怕我需要更多的指導,因為我以前從未使用過 Expr () 和 Insert NameExpr () 函數。 如果您可以提供一個帶有我在 OP 中添加的範例腳本的範例,那將會很有用。
回覆:如何從 JSL 中的列表傳遞 Graph Builder 中的 Y 變數?這不僅是構建這個的選項,而且可以提供一些想法。 也可以搜尋 GraphBuilderbox 的變數和元素的腳本索引
Names Default To Here(1);
dt = Open("$sample_data\Big Class.jmp");
y_values = {"name", "age", "sex", "weight"};
variables_expr = Expr(Variables(X(:height)));
For Each({y_col}, y_values,
temp_expr = Expr(Y());
Insert Into(temp_expr, Name Expr(AsColumn(dt, y_col)));
Insert Into(variables_expr, Name Expr(temp_expr));
);
gb_expr = Expr(Graph Builder(
Show Control Panel(0)
));
Insert Into(gb_expr, Name Expr(variables_expr));
For Each({y_col, idx}, y_values,
Eval(EvalExpr(
Insert Into(gb_expr,
Name Expr(Elements(Position(1, Expr(idx)), Points(X, Y, Legend(Expr(idx)))))
)
));
);
Show(Name Expr(gb_expr));
Eval(gb_expr);
編輯:
使用 Add Variable() 的範例
Names Default To Here(1);
dt = Open("$sample_data\Big Class.jmp");
y_values = {"name", "age", "sex", "weight"};
variables_expr = Expr(Variables(X(:height)));
gb = dt << Graph Builder(
// Ignore Platform Preferences(1),
Show control Panel(0),
Variables(X(:height))
);
gb << inval;
For Each({y_col, idx}, y_values,
Eval(EvalExpr(
gb << Add Variable({Expr(Name Expr(As Column(dt, y_col))), Role("Y")})
));
// if you just want points, you shouldn't need this, but smoother idx is 2 instead of 1
/* gb << Remove Element(1, idx, 1);
Eval(EvalExpr(
gb << Add Element(1, Expr(idx), {Type("Points"), X, Y, Legend(Expr(idx))})
));
*/
);
gb << Update window;
gb << Remove Element(1, N Items(y_values), 2); // 1 or 2 for smoother idx, depending on how GB is built回覆:如何從 JSL 中的列表傳遞 Graph Builder 中的 Y 變數?@jthi謝謝。 這對我有用,但我無法更改預設的圖表標題。 如何透過 JSL 執行此操作?
回覆:如何從 JSL 中的列表傳遞 Graph Builder 中的 Y 變數?取決於您定義的標題。
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(
Variables(X(:height), Y(:weight)),
Elements(Points(X, Y), Smoother(X, Y))
);
gb << Title("Test");
如果您認為它是圖形產生器上方的文字編輯框,請手動變更它,然後修改 JMP 建立的腳本。
SendToReport(Dispatch({}, "graph title", TextEditBox, {Set Text("asdsad")}))
如果您有 JMP17 並使用屬性,您可以獲得更多信息

所以像
Report(gb)[TextEditBox(1)] << Set Text("12313213");
可能會起作用,具體取決於您的報告
回覆:如何從 JSL 中的列表傳遞 Graph Builder 中的 Y 變數?@jthi謝謝。 對於您展示的簡單案例,我知道如何放置圖表標題(如您所示),但是對於下面的案例如何做到這一點?
Names Default To Here(1);
dt = Open("$sample_data\Big Class.jmp");
y_values = {"name", "age", "sex", "weight"};
variables_expr = Expr(Variables(X(:height)));
For Each({y_col}, y_values,
temp_expr = Expr(Y());
Insert Into(temp_expr, Name Expr(AsColumn(dt, y_col)));
Insert Into(variables_expr, Name Expr(temp_expr));
);
gb_expr = Expr(Graph Builder(
Show Control Panel(0)
));
Insert Into(gb_expr, Name Expr(variables_expr));
For Each({y_col, idx}, y_values,
Eval(EvalExpr(
Insert Into(gb_expr,
Name Expr(Elements(Position(1, Expr(idx)), Points(X, Y, Legend(Expr(idx)))))
)
));
);
Show(Name Expr(gb_expr));
Eval(gb_expr);回覆:如何從 JSL 中的列表傳遞 Graph Builder 中的 Y 變數?參考圖形產生器,這兩個想法都應該可行
回覆:如何從 JSL 中的列表傳遞 Graph Builder 中的 Y 變數?@jthi謝謝,但在腳本索引中沒有看到 Get Reference ()(我使用的是 JMP 16.2.0)。 您的意思是取得圖形產生器視窗的視窗名稱嗎?
回覆:如何從 JSL 中的列表傳遞 Graph Builder 中的 Y 變數?Current Report()[TextEditBox( 1 )] << set text( "NewTitle" );
這對我有用。
回覆:如何從 JSL 中的列表傳遞 Graph Builder 中的 Y 變數?我建議您在評估建立圖形的表達式時取得參考。 我認為
gb = Eval(gb_expr);
應該管用。 此外,如果可能開啟多個表,那麼確保使用 dt 建立圖形產生器可能是個好主意。 儘管我不確定在這種情況下無需測試最簡單的語法是什麼
回覆:如何從 JSL 中的列表傳遞 Graph Builder 中的 Y 變數?您可以為表達式產生符號 var 和 gb
Var= Expr(variables(x(:height)))
gb =Expr(Graph Builder())
然後使用插入在一個為了循環用 Ys 填滿 var ,然後插入名稱表達式(var)進入國標然後使用另一個為了循環加入 Elements 表達式。