Here is the best solution I could come up with. In a nutshell it makes two grouping variables and then maps the one group to a 100% transparent element. Then it just has two element calls in the GPL (in this example one for linear and one for quadratic).

Of course the most flexible solution would be to actually fit the models for each group and put the predicted values as a new variable in the dataset, but this didn't work out too badly (the legend didn't even turn out that badly).

```
**********************************************.
set seed = 10.
input program.
loop #i = 1 to 100.
if #i <= 50 group = 0.
if #i > 50 group = 1.
end case.
end loop.
end file.
end input program.
dataset name sim.
execute.
compute x = RV.NORM(0,1).
if group = 0 outcome = x + RV.NORM(0,0.1).
if group = 1 outcome = x**2 + RV.NORM(0,0.1).
compute group_square = (group = 1).
compute group_linear = (group = 0).
formats all (F1.0).
exe.
DATASET ACTIVATE sim.
* Chart Builder.
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=x outcome group_square group_linear group
MISSING=LISTWISE REPORTMISSING=NO
/GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
SOURCE: s=userSource(id("graphdataset"))
DATA: x=col(source(s), name("x"))
DATA: outcome=col(source(s), name("outcome"))
DATA: group=col(source(s), name("group"), unit.category())
DATA: group_square=col(source(s), name("group_square"), unit.category())
DATA: group_linear=col(source(s), name("group_linear"), unit.category())
GUIDE: axis(dim(1), label("x"))
GUIDE: axis(dim(2), label("outcome"))
GUIDE: legend(aesthetic(aesthetic.transparency), null())
SCALE: cat(aesthetic(aesthetic.transparency), map(("0", transparency."1.0"), ("1", transparency."0.0")))
ELEMENT: point(position(x*outcome), color.exterior(group))
ELEMENT: line(position(smooth.linear(x*outcome)), transparency.interior(group_linear), color.interior(group))
ELEMENT: line(position(smooth.quadratic(x*outcome)), transparency.interior(group_square), color.interior(group))
END GPL.
**********************************************.
```