Non-standard Boxplot

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

Non-standard Boxplot

Kirill Orlov
Is it possible to produce a Boxplot showing mean (instead of median),
and sigmas (instead of interquartile range and/or whiskers)?
Is it possible to produce a Boxplot directly specifying in syntax the
values (Y coordinates) for these elements (middle line, box, whiskers)?
It seems to me that it is impossible (couldn'r find anything such in GPL
guide).

=====================
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: Non-standard Boxplot

Andy W
Here are a few examples.

****************************************************************************.
DATA LIST FREE / Group MeanY SDY WhiskL WhiskH.
BEGIN DATA
1 1 3 -6 10
2 5 1  0  8
3 5 4  -6 14
END DATA.
DATASET NAME Me.
EXECUTE.

VALUE LABELS Group
 1 'A'
 2 'B'
 3 'C'
.

*This is the typical, where the boxes are only defined for categorical
variables.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Group MeanY SDY WhiskL WhiskH
  /GRAPHSPEC SOURCE=INLINE
  /FRAME INNER=YES.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: Group=col(source(s), name("Group"), unit.category())
  DATA: MeanY=col(source(s), name("MeanY"))
  DATA: SDY=col(source(s), name("SDY"))
  DATA: WhiskL=col(source(s), name("WhiskL"))
  DATA: WhiskH=col(source(s), name("WhiskH"))
  TRANS: lowY = eval(MeanY - 1.96*SDY)
  TRANS: highY = eval(MeanY + 1.96*SDY)
  GUIDE: axis(dim(1), label("Group"))
  GUIDE: axis(dim(2), label("Y Stats"))
  ELEMENT: edge(position(region.spread.range(Group*(WhiskL+WhiskH))))
  ELEMENT: interval(position(region.spread.range(Group*(lowY+highY))))
  ELEMENT: point(position(Group*MeanY))
END GPL.


*If you want to do the boxes in continuous space on the X axis.
COMPUTE XLoc = GROUP + RV.UNIFORM(-0.8,0.8).
EXECUTE.

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=XLoc MeanY SDY WhiskL WhiskH
  /GRAPHSPEC SOURCE=INLINE
  /FRAME INNER=YES.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: XLoc=col(source(s), name("XLoc"))
  DATA: MeanY=col(source(s), name("MeanY"))
  DATA: SDY=col(source(s), name("SDY"))
  DATA: WhiskL=col(source(s), name("WhiskL"))
  DATA: WhiskH=col(source(s), name("WhiskH"))
  TRANS: lowY = eval(MeanY - 1.96*SDY)
  TRANS: highY = eval(MeanY + 1.96*SDY)
  GUIDE: axis(dim(1), label("X Continuous"))
  GUIDE: axis(dim(2), label("Y Stats"))
  ELEMENT: edge(position(region.spread.range(XLoc*(WhiskL+WhiskH))))
  ELEMENT: interval(position(region.spread.range(XLoc*(lowY+highY))),
size(size."10"))
  ELEMENT: point(position(XLoc*MeanY))
END GPL.

*If you wanted to totally specify the coordinates of the boxes, see
*here for example.
*http://spssx-discussion.1045642.n5.nabble.com/Changing-color-of-chart-background-based-on-value-td5739739.html#a5739749
****************************************************************************.



-----
Andy W
[hidden email]
http://andrewpwheeler.wordpress.com/
--
Sent from: http://spssx-discussion.1045642.n5.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
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Non-standard Boxplot

Kirill Orlov
That was very helpful, Andy. Thank you!

=====================
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