Andy, Thank you for your replies. I'll investigate editing the template, which does kind of scare me. I understand about not being able to control legend placement, which is quite unfortunate and a surprising limitation for what purports to be, i.e., a graphics production language.
Continuation of yesterday's questions. Here's the GPL syntax. I get the two lines, one solid with points circled, one dashed (unexpected dash structure) with points squared. GGRAPH /GRAPHDATASET NAME="GraphDataset" VARIABLES=time cig6_r RADST/ GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("GraphDataset")) DATA: time=col(source(s), name("time")) DATA: cig6_r=col(source(s), name("cig6_r"), unit.category()) DATA: RADST=col(source(s), name("RADST")) GUIDE: axis(dim(1), label("Assessment Time Point (Yrs)"), start(0), delta(.5)) GUIDE: axis(dim(2), label("Mean Depression Total Score Percentile"), start(46), delta(5)) SCALE: linear(dim(2), min(46), max(62)) ELEMENT: point(position(summary.mean(time*RADST)), shape(cig6_r)) ELEMENT: line(position(summary.mean(time*RADST)), shape(cig6_r)) END GPL. Main question. I want to show 1 SD error bars. Basic command is 'alpha(0.6826)'. Problem seems to be that I cannot use 'shape(cig6_r)' to control placement of the error bar relative to each line. I actually think that what is happening is that the error bar is being computed and located based on the combined (cig6_r=0 & cig6_r=1) set of values. The statement I tried and which gives errors is ELEMENT: interval(position(region.confi.mean(time*RADST, alpha(0.6826))), shape(shape.ibeam), size(size.".2in"), color(color.black), shape(cig6_r)) Secondary question. So suppose I want to have both lines to be solid. It seems that the 'shape(cig6_r)' clause controls two things simultaneously. One is that it causes cycling through the values of cig6_r and it controls cycling through the point/line display types. How do I cause both lines to be solid? Thanks, Gene Maguin ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
It won't help with the legend placement, but if you look in your SPSS installation directory its come with several chart template variants. In my V22 in the looks folder (not the template folder!) there is a chart template named "APA_Styles.sgt" - it probably gets you closer to the APA style guide with less editing.
It always help if you give a set of data that looks like yours. In your plot you have time and RADST as continuous values. So "region.confi.mean" won't work, as it doesn't know where to calculate the means for continuous data. (Another problem is you have shape specified twice, once as shape.ibeam and another mapping shape to cig6_r). Perhaps try (for continuous error intervals): ELEMENT: line(position(region.confi.smooth.linear(time*RADST, alpha(0.6826))), size(size.".2in"), color(color.black), shape(cig6_r)) This will provide a line for the upper and lower interval (you could also use area to provide shading for the entire error interval) continuously over values of time. Or you could change time to a categorical variable (which is fine if you only sampled at regular time intervals) to display the error bars at the regular intervals: DATA: time=col(source(s), name("time"), unit.category()) For the secondary question, you need to map the aesthetics to categories. It doesn't make any sense to map cig6_r to shape if you don't want to change the shape of the line though. So if you only want straight lines, simply omit the "shape(cig6_r)" part on the line element. I'm sure APA allows grey scale, so you could map cig6_r to different shades of grey for the lines. Something like this (pretending cig6_r only takes on values of 1 and 2): SCALE: cat(aesthetic(aesthetic.color.interior), map(("1",color.black),("2",color."111111"))) ELEMENT: point(position(summary.mean(time*RADST)), shape(cig6_r), color.interior(cig6_r)) ELEMENT: line(position(summary.mean(time*RADST)), color.interior(cig6_r)) |
(text deleted. Embedded replies)
-----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Andy W Sent: Tuesday, June 10, 2014 12:30 PM To: [hidden email] Subject: Re: follow up GPL question (2) It always help if you give a set of data that looks like yours. >>I've put example data at the bottom of the message. In your plot you have time and RADST as continuous values. So "region.confi.mean" won't work, as it doesn't know where to calculate the means for continuous data. >> I understand your point. Time is declared nominal in the dataset. But, changing the level to 'scale' and leaving out the unit.category() clause does not yield an error. When a pair of variables are named as in 'a*b', a is assumed to be x-axis variable and b the y-axis variable--seems to be anyway. (Another problem is you have shape specified twice, once as shape.ibeam and another mapping shape to cig6_r). Perhaps try (for continuous error intervals): ELEMENT: line(position(region.confi.smooth.linear(time*RADST, alpha(0.6826))), size(size.".2in"), color(color.black), shape(cig6_r)) This will provide a line for the upper and lower interval (you could also use area to provide shading for the entire error interval) continuously over values of time. >>No. If the plot lines were linear this might work. Don't know. Not sure how the underlying computation works. But the plot lines are cubic+. Or you could change time to a categorical variable (which is fine if you only sampled at regular time intervals) to display the error bars at the regular intervals: DATA: time=col(source(s), name("time"), unit.category()) For the secondary question, you need to map the aesthetics to categories. It doesn't make any sense to map cig6_r to shape if you don't want to change the shape of the line though. So if you only want straight lines, simply omit the "shape(cig6_r)" part on the line element. >> if I omit the shape(cig6_r) clause, the plotted line looks to be the mean of the data values at the time point. The points themselves are plotted correctly. So, it appears to me that the shape clause simultaneously has two functions. Sample data begins here. print / id time radst(f1.0,f4.1,f6.2). 1 .0 53.37 1 .5 51.47 1 1.0 59.13 1 1.5 57.12 1 2.0 59.52 1 2.5 54.89 1 3.0 54.55 2 .0 55.67 2 .5 53.73 2 1.0 52.12 2 1.5 53.23 2 2.0 53.95 2 2.5 59.30 2 3.0 50.82 3 .0 58.10 3 .5 57.79 3 1.0 57.28 3 1.5 52.96 3 2.0 59.97 3 2.5 53.36 3 3.0 56.15 4 .0 50.56 4 .5 51.83 4 1.0 50.84 4 1.5 57.31 4 2.0 57.31 4 2.5 59.56 4 3.0 42.98 5 .0 57.24 5 .5 56.57 5 1.0 56.77 5 1.5 55.27 5 2.0 52.63 5 2.5 53.14 5 3.0 64.00 6 .0 55.82 6 .5 50.65 6 1.0 47.10 6 1.5 52.37 6 2.0 56.26 6 2.5 58.32 6 3.0 46.71 7 .0 54.86 7 .5 57.08 7 1.0 54.78 7 1.5 54.41 7 2.0 52.44 7 2.5 54.36 7 3.0 57.60 ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Below are a few examples. My guess as to your point about the shape problem is that groups are being aggregated that you don't want aggregated in the summary calculations? The split modifier can be used to split graphical elements that still share the same attributes, but I don't know how they interact with the inline summary functions.
Let me know if you have any questions about the code. ***************************************************************************. DATA LIST FREE / id time radst (f1.0,f4.1,f6.2). BEGIN DATA 1 .0 53.37 1 .5 51.47 1 1.0 59.13 1 1.5 57.12 1 2.0 59.52 1 2.5 54.89 1 3.0 54.55 2 .0 55.67 2 .5 53.73 2 1.0 52.12 2 1.5 53.23 2 2.0 53.95 2 2.5 59.30 2 3.0 50.82 3 .0 58.10 3 .5 57.79 3 1.0 57.28 3 1.5 52.96 3 2.0 59.97 3 2.5 53.36 3 3.0 56.15 4 .0 50.56 4 .5 51.83 4 1.0 50.84 4 1.5 57.31 4 2.0 57.31 4 2.5 59.56 4 3.0 42.98 5 .0 57.24 5 .5 56.57 5 1.0 56.77 5 1.5 55.27 5 2.0 52.63 5 2.5 53.14 5 3.0 64.00 6 .0 55.82 6 .5 50.65 6 1.0 47.10 6 1.5 52.37 6 2.0 56.26 6 2.5 58.32 6 3.0 46.71 7 .0 54.86 7 .5 57.08 7 1.0 54.78 7 1.5 54.41 7 2.0 52.44 7 2.5 54.36 7 3.0 57.60 END DATA. DATASET NAME Graph. *Creating cig6_r variable. RECODE id (1 THRU 3 = 1)(ELSE = 2) INTO cig6_r. FORMATS cig6_r (F1.0). VALUE LABELS cig6_r 1 'Group 1' 2 'Group 2'. EXECUTE. *Graph with individual trajectories. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=time radst id cig6_r /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: time=col(source(s), name("time")) DATA: radst=col(source(s), name("radst")) DATA: id=col(source(s), name("id"), unit.category()) DATA: cig6_r=col(source(s), name("cig6_r"), unit.category()) GUIDE: axis(dim(1), label("time")) GUIDE: axis(dim(2), label("radst")) GUIDE: legend(aesthetic(aesthetic.color.interior), label("cig6_r")) SCALE: cat(aesthetic(aesthetic.color.interior), map(("1",color.black),("2",color."999999"))) ELEMENT: line(position(time*radst), color.interior(cig6_r), split(id)) END GPL. *Making graph with means of the trajectories (continuous X axis). GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=time radst id cig6_r /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: time=col(source(s), name("time")) DATA: radst=col(source(s), name("radst")) DATA: id=col(source(s), name("id"), unit.category()) DATA: cig6_r=col(source(s), name("cig6_r"), unit.category()) GUIDE: axis(dim(1), label("time")) GUIDE: axis(dim(2), label("radst")) GUIDE: legend(aesthetic(aesthetic.color.interior), label("cig6_r")) SCALE: cat(aesthetic(aesthetic.color.interior), map(("1",color.black),("2",color."999999"))) ELEMENT: line(position(summary.mean(time*radst)), color.interior(cig6_r)) ELEMENT: point(position(summary.mean(time*radst)), color.interior(cig6_r), shape(cig6_r)) END GPL. *Now adding in error bars. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=time radst id cig6_r /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: time=col(source(s), name("time")) DATA: radst=col(source(s), name("radst")) DATA: id=col(source(s), name("id"), unit.category()) DATA: cig6_r=col(source(s), name("cig6_r"), unit.category()) GUIDE: axis(dim(1), label("time")) GUIDE: axis(dim(2), label("radst")) GUIDE: legend(aesthetic(aesthetic.color.interior), label("cig6_r")) SCALE: cat(aesthetic(aesthetic.color.interior), map(("1",color.black),("2",color."999999"))) ELEMENT: area(position(region.confi.mean(time*radst, alpha(0.6826))), color(cig6_r), transparency.interior(transparency."0.5")) ELEMENT: line(position(summary.mean(time*radst)), color.interior(cig6_r)) ELEMENT: point(position(summary.mean(time*radst)), color.interior(cig6_r), shape(cig6_r)) END GPL. *Looks much clearer if you use paneling. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=time radst id cig6_r /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: time=col(source(s), name("time")) DATA: radst=col(source(s), name("radst")) DATA: id=col(source(s), name("id"), unit.category()) DATA: cig6_r=col(source(s), name("cig6_r"), unit.category()) GUIDE: axis(dim(1), label("time")) GUIDE: axis(dim(2), label("radst")) GUIDE: axis(dim(3), opposite()) GUIDE: legend(aesthetic(aesthetic.color.interior), null()) GUIDE: legend(aesthetic(aesthetic.shape.interior), null()) SCALE: cat(aesthetic(aesthetic.color.interior), map(("1",color.black),("2",color."999999"))) ELEMENT: area(position(region.confi.mean(time*radst*cig6_r, alpha(0.6826))), color(cig6_r), transparency.interior(transparency."0.5")) ELEMENT: line(position(summary.mean(time*radst*cig6_r)), color.interior(cig6_r)) ELEMENT: point(position(summary.mean(time*radst*cig6_r)), color.interior(cig6_r), shape(cig6_r)) END GPL. *Using smooth functions. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=time radst id cig6_r /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: time=col(source(s), name("time")) DATA: radst=col(source(s), name("radst")) DATA: id=col(source(s), name("id"), unit.category()) DATA: cig6_r=col(source(s), name("cig6_r"), unit.category()) GUIDE: axis(dim(1), label("time")) GUIDE: axis(dim(2), label("radst")) GUIDE: axis(dim(3), opposite()) GUIDE: legend(aesthetic(aesthetic.color.interior), null()) GUIDE: legend(aesthetic(aesthetic.shape.interior), null()) SCALE: cat(aesthetic(aesthetic.color.interior), map(("1",color.black),("2",color."999999"))) ELEMENT: area(position(region.confi.smooth.cubic(time*radst*cig6_r)), color(cig6_r), transparency.interior(transparency."0.5")) ELEMENT: line(position(summary.mean(time*radst*cig6_r)), color.interior(cig6_r)) ELEMENT: point(position(summary.mean(time*radst*cig6_r)), color.interior(cig6_r), shape(cig6_r)) END GPL. *Not a good fit - too noisy to make such an assertion. *Making graph with means categorical. GGRAPH /GRAPHDATASET NAME="graphdataset" VARIABLES=time radst id cig6_r /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("graphdataset")) DATA: time=col(source(s), name("time"), unit.category()) DATA: radst=col(source(s), name("radst")) DATA: id=col(source(s), name("id"), unit.category()) DATA: cig6_r=col(source(s), name("cig6_r"), unit.category()) GUIDE: axis(dim(1), label("time")) GUIDE: axis(dim(2), label("radst")) GUIDE: axis(dim(3), opposite()) GUIDE: legend(aesthetic(aesthetic.color.interior), null()) GUIDE: legend(aesthetic(aesthetic.shape.interior), null()) SCALE: cat(aesthetic(aesthetic.color.interior), map(("1",color.black),("2",color."999999"))) ELEMENT: interval(position(region.confi.mean(time*radst*cig6_r, alpha(0.6826))), color(cig6_r), shape(shape.ibeam)) ELEMENT: line(position(summary.mean(time*radst*cig6_r)), color.interior(cig6_r)) ELEMENT: point(position(summary.mean(time*radst*cig6_r)), color.interior(cig6_r), shape(cig6_r)) END GPL. *Dodging is another potential option, but small multiples is much clearer IMO. ***************************************************************************. |
Free forum by Nabble | Edit this page |