You should be able to call the function where you wish to have the graphs at
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
create_plot = function({dt, colname}, {Default Local},
gb = dt << Graph Builder(
Variables(X(:age), Y(Eval(colname)), Overlay(:sex)),
Elements(Points(X, Y, Legend(9)), Line Of Fit(X, Y, Legend(11)))
);
return(gb);
);
plots = {};
nw = new window("",
V List Box(
Insert Into(plots, create_plot(dt, "height")),
Insert Into(plots, create_plot(dt, "weight"))
)
);
If you do not need the list for reference collection, you can just drop it
nw = new window("",
V List Box(
gb_height = create_plot(dt, "height"),
gb_weight = create_plot(dt, "weight")
)
);
or just
nw = new window("",
V List Box(
create_plot(dt, "height"),
create_plot(dt, "weight")
)
);
and idea would be similar for multiple windows
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
create_plot = function({dt, colname}, {Default Local},
gb = dt << Graph Builder(
Variables(X(:age), Y(Eval(colname)), Overlay(:sex)),
Elements(Points(X, Y, Legend(9)), Line Of Fit(X, Y, Legend(11)))
);
return(gb);
);
nw = new window("",
create_plot(dt, "height")
);
nw = new window("",
create_plot(dt, "weight")
);
Or sometimes you might not need the new window
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
create_plot = function({dt, colname}, {Default Local},
gb = dt << Graph Builder(
Variables(X(:age), Y(Eval(colname)), Overlay(:sex)),
Elements(Points(X, Y, Legend(9)), Line Of Fit(X, Y, Legend(11)))
);
return(gb);
);
gb1 = create_plot(dt, "height");
gb2 = create_plot(dt, "weight");
-Jarmo