Hi, First off all thanks for your time. data list list /var1 var2. begin data. 1 1 3 1 5 3 6 4 7 5 8 3 5 5 6 7 7 3 end data. execute. numeric id(f8.0). compute id=$casenum. execute. variable level all (scale). GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=id var1 var2 MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: id=col(source(s), name("id")) DATA: var1=col(source(s), name("var1")) DATA: var2=col(source(s), name("var2")) GUIDE: axis(dim(1), label("id")) GUIDE: axis(dim(2), label("")) SCALE: linear (dim(2), min(0), max(12)) ELEMENT: line(position(id*var1), missing.wings()) ELEMENT: point(position(id*var1), color(color.black), shape(shape.circle), transparency.interior(transparency."0.1")) ELEMENT: line(position(id*var2), color(color.red), missing.wings()) ELEMENT: point(position(id*var2), color(color.red), shape(shape.circle), transparency.interior(transparency."0.1")) END GPL. /line(MULTIPLE)=value (var1 var2). |
Thank you for the reproducible example. You need to map the aesthetics to get a legend. So in the ELEMENT lines place a reference to either a data variable or a quoted label. Then to get things the colors you want, you need to specify them in a SCALE line.
*******************************************************. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=id var1 var2 MISSING=LISTWISE REPORTMISSING=NO /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: id=col(source(s), name("id")) DATA: var1=col(source(s), name("var1")) DATA: var2=col(source(s), name("var2")) GUIDE: axis(dim(1), label("id")) GUIDE: axis(dim(2), label("")) SCALE: linear (dim(2), min(0), max(12)) SCALE: cat(aesthetic(aesthetic.color.interior), map(("Var1",color.black),("Var2",color.red))) ELEMENT: line(position(id*var1), color("Var1")) ELEMENT: point(position(id*var1), color.interior("Var1"), shape(shape.circle), transparency.interior(transparency."0.1")) ELEMENT: line(position(id*var2), color("Var2"), missing.wings()) ELEMENT: point(position(id*var2), color.interior("Var2"), shape(shape.circle), transparency.interior(transparency."0.1")) END GPL. *******************************************************. |
In reply to this post by 88videos
Thanks. !!! I didn't know how to use map function. |
Free forum by Nabble | Edit this page |