Help with GPL

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with GPL

JeremyT
I hope that some of you are experts in SPSS GPL!  I have 4 variables, Colour, Mean, Upper and Lower, with Colour being the categorical variable and the other variables containing the mean and  upper and lower bounds of an interval. For example:

Colour  Mean  Low  Up
Blue    310     295   330
Red     220     200   225
Green  355     340   395

I can generate a bar chart with GPL (code below) but I cannot work out how to add an ibeam to each bar defined by the upper and lower limits .  Any help will be very welcome.  

Thanks!

Jeremy


GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Colour  Mean Lower Upper MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: Colour=col(source(s), name("Colour"), unit.category())
  DATA: Mean=col(source(s), name("Mean"))
  DATA: Lower=col(source(s), name("Lower"))
  DATA: Upper=col(source(s), name("Upper"))
  GUIDE: axis(dim(1), label("Colour"))
  GUIDE: axis(dim(2), label("Mean Reading"))
  SCALE: linear(dim(2), include(0))
  ELEMENT: interval(position(Colour*Mean), shape.interior(shape.square))
END GPL.
Reply | Threaded
Open this post in threaded view
|

Re: Help with GPL

ViAnn Beadle
data list list / colour (a10) mean low up (3f3.0).
begin data
Blue    310     295   330
Red     220     200   225
Green  355     340   395
end data.


GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=colour up low mean
MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: colour=col(source(s), name("colour"), unit.category())
  DATA:up=col(source(s), name("up"))
  DATA: low=col(source(s), name("low"))
  DATA:mean=col(source(s), name("mean"))
  GUIDE: axis(dim(1), label("colour"))
  GUIDE: axis(dim(2), label("choose your own label"))
  SCALE: linear(dim(2), include(0))
  ELEMENT: interval(position(region.spread.range(colour*(low+up))),
    shape(shape.ibeam))
  ELEMENT: point(position(colour*mean), shape(shape.circle))
END GPL.

I used Chart Builder to generate a high-low-close chart and then edited it
to get to here.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
JeremyT
Sent: Monday, November 21, 2011 8:18 AM
To: [hidden email]
Subject: Help with GPL

I hope that some of you are experts in SPSS GPL!  I have 4 variables,
Colour, Mean, Upper and Lower, with Colour being the categorical variable
and the other variables containing the mean and  upper and lower bounds of
an interval. For example:

*Colour  Mean  Low  Up*
Blue    310     295   330
Red     220     200   225
Green  355     340   395

I can generate a bar chart with GPL (code below) but I cannot work out how
to add an ibeam to each bar defined by the upper and lower limits .  Any
help will be very welcome.

Thanks!

Jeremy


GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Colour  Mean Lower Upper
MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: Colour=col(source(s), name("Colour"), unit.category())
  DATA: Mean=col(source(s), name("Mean"))
  DATA: Lower=col(source(s), name("Lower"))
  DATA: Upper=col(source(s), name("Upper"))
  GUIDE: axis(dim(1), label("Colour"))
  GUIDE: axis(dim(2), label("Mean Reading"))
  SCALE: linear(dim(2), include(0))
  ELEMENT: interval(position(Colour*Mean), shape.interior(shape.square)) END
GPL.


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Help-with-GPL-tp5010786p501078
6.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
Reply | Threaded
Open this post in threaded view
|

Re: Help with GPL

JeremyT
Brilliant!  Many thanks. It was the Element statement I was having trouble with as I had not found the region.spread.range function in the guide.

Jeremy