Hi all, I have created a weighted kernel density graph using the GPL syntax below (modified from
http://andrewpwheeler.wordpress.com/2012/04/29/comparing-continuous-distributions-of-unequal-size-groups-in-spss/).
The Y axis values are displayed in scientific notation, which I would like to change to decimal. If I double-click on the graph, select the axis values, and go to the ‘Number Format’ properties, ‘Scientific Notation’ is already set to ‘Never’
and changing the ‘Decimal Places’ and ‘Scaling Factor’ options have to no effect. Any suggestions? Can I specify the use of decimal format in the GPL code itself? Thanks, Kylie. GGRAPH /GRAPHDATASET NAME="DataSet1" VARIABLES=KcalIn.24hrs Group2 myweight
/GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("DataSet1"), weight(weightedVar)) DATA: weightedVar=col(source(s), name("myweight")) DATA: Kcal =col(source(s), name("KcalIn.24hrs")) DATA: Group2=col(source(s), name("Group2"), unit.category()) GUIDE: axis(dim(1), label("Calories per day")) GUIDE: axis(dim(2), label("Weighted Kernel Density Estimate")) GUIDE: legend(aesthetic(aesthetic.color.interior)) SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2")) SCALE: linear(dim(2)) ELEMENT: line(position(density.kernel.epanechnikov(Kcal*Group2)), color(Group2)) END GPL. |
Not sure how to fix that easily. Maybe see if you can either edit the chart template or make a new chart template to get the desired behavior.
Another option might be to make a false set of variables (either within the actual SPSS dataset or using TRANS commands in the inline GPL) to initialize the axis. Something like below: *****************************************************. *or set y to another reasonable value given your density. compute y = 0.01. format y (F4.3). GGRAPH /GRAPHDATASET NAME="DataSet1" VARIABLES=KcalIn.24hrs Group2 myweight y /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("DataSet1"), weight(weightedVar)) DATA: weightedVar=col(source(s), name("myweight")) DATA: Kcal =col(source(s), name("KcalIn.24hrs")) DATA: Group2=col(source(s), name("Group2"), unit.category()) DATA: y=col(source(s), name("y")) GUIDE: axis(dim(1), label("Calories per day")) GUIDE: axis(dim(2), label("Weighted Kernel Density Estimate")) GUIDE: legend(aesthetic(aesthetic.color.interior)) SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2")) SCALE: linear(dim(2)) ELEMENT: point(position(Kcal*y), transparency.exterior(transparency."1")) ELEMENT: line(position(density.kernel.epanechnikov(Kcal*Group2)), color(Group2)) END GPL. *****************************************************. The y axis should be initialized to the fake y variable and its format, but the points should not be drawn (as they are set to 100% transparent). Also see the visible.false function to accomplish the same thing without drawing the needless invisible geometries in the plot. I've had to do this sometimes for KDE charts to draw a y axis at all I believe. |
Thanks for the reply Andy. I had success with using the Y variable as you suggested below. In my case I used:
COMPUTE y = 0.001. FORMATS y (F5.4). to get the range I needed. A useful trick! Thanks again - for the original blog post and your response. Kylie. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Andy W Sent: Monday, 20 January 2014 12:35 PM To: [hidden email] Subject: Re: turning off scientific notation in GPL graph Not sure how to fix that easily. Maybe see if you can either edit the chart template or make a new chart template to get the desired behavior. Another option might be to make a false set of variables (either within the actual SPSS dataset or using TRANS commands in the inline GPL) to initialize the axis. Something like below: *****************************************************. *or set y to another reasonable value given your density. compute y = 0.01. format y (F4.3). GGRAPH /GRAPHDATASET NAME="DataSet1" VARIABLES=KcalIn.24hrs Group2 myweight y /GRAPHSPEC SOURCE=INLINE. BEGIN GPL SOURCE: s=userSource(id("DataSet1"), weight(weightedVar)) DATA: weightedVar=col(source(s), name("myweight")) DATA: Kcal =col(source(s), name("KcalIn.24hrs")) DATA: Group2=col(source(s), name("Group2"), unit.category()) DATA: y=col(source(s), name("y")) GUIDE: axis(dim(1), label("Calories per day")) GUIDE: axis(dim(2), label("Weighted Kernel Density Estimate")) GUIDE: legend(aesthetic(aesthetic.color.interior)) SCALE: cat(aesthetic(aesthetic.color.interior), include("1", "2")) SCALE: linear(dim(2)) ELEMENT: point(position(Kcal*y), transparency.exterior(transparency."1")) ELEMENT: line(position(density.kernel.epanechnikov(Kcal*Group2)), color(Group2)) END GPL. *****************************************************. The y axis should be initialized to the fake y variable and its format, but the points should not be drawn (as they are set to 100% transparent). Also see the visible.false function to accomplish the same thing without drawing the needless invisible geometries in the plot. I've had to do this sometimes for KDE charts to draw a y axis at all I believe. ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/turning-off-scientific-notation-in-GPL-graph-tp5724008p5724010.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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 ===================== 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 |
Free forum by Nabble | Edit this page |