No sure if you can access those "names" (groupings) from graph builder. You can check what you can access with Xpath by using << Get XML on win variable and based on that there is no mention of "Female" and "Male". Also checking from Show Tree Structure and Show Properties I cannot see them there either:
To get a reference to GraphBuilderGroupBox you can use:
gbgb = Report(win)[GraphBuilderGroupBox(1)];
//or
gbgb = (win << XPath("//GraphBuilderGroupBox"))[1]; //it is a list so use index
Accessing the Group X can be done with Variable, but I'm not sure if it will be helpful here:
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Academic Achievement.jmp");
win = dt << Graph Builder(
Size(570, 475),
Variables(X(:Year4), Y(:Year2), Group X(:Female)),
Elements(Points(X, Y, Legend(8)), Smoother(X, Y, Legend(9)))
);
//win << get xml
gbb = Report(win)[Graph Builder Box(1)];
wait(1);
gbb << Remove Variable(3);
gbb << Add Variable({:Female Binary, Role("Group X")});
Edit:
If you need just the values of Female column, you can get them directly from datatable. As these are value labels, you have to get value label property
(Column(dt, "Female") << Get Column Properties())["Value Labels"]
-Jarmo