This isn't only option of building this but can give some ideas. Also search scripting index for Variable and Element for 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);
Edit:
One example using 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
-Jarmo