graph with lines and labels

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

graph with lines and labels

Eva Wouda
Dear all,

I am trying to get grouped line graphs. My syntax now looks like this:


* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=ageSBR MEDIAN(result)[name="MEDIAN_result"] ABE egawk
    MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  PAGE: begin(scale(1000px,2500px))  SOURCE: s=userSource(id("graphdataset"))
  DATA: ageSBR=col(source(s), name("ageSBR"))
  DATA: MEDIAN_result=col(source(s), name("MEDIAN_result"))
  DATA: ABE=col(source(s), name("ABE"), unit.category())
  DATA: egawk=col(source(s), name("egawk"), unit.category())
  GUIDE: axis(dim(1), label("Age of the baby in hours at time of SBR measurement"))
  GUIDE: axis(dim(2), delta(50), label("Median Result of SBR level in mgr/L"))
  GUIDE: axis(dim(4), label("ega in weeks, egadob truncated"), opposite())
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("ABE signs following study definition"))
  SCALE: linear(dim(1), max(360))
  SCALE: linear(dim(2), max(800))
  SCALE: cat(aesthetic(aesthetic.color.interior), include("2", "1", "0"), sort.values("2", "1",
    "0"))
  ELEMENT: line(position(ageSBR*MEDIAN_result*1*egawk), color.interior(ABE), missing.interpolate())
  PAGE: end()
END GPL.

 I’d like to have graphs grouped on ega in weeks (egawk) showing three lines that refer to three categories of the variable ABE. With result on Y and age on X.
This is working now. But I’d like to have a label to every line which will tell me the count of cases that were available to create this line. So for example the line ABE=2 has 2 cases for ega=32, then I would like to see a label with 2. Or the line ABE=1 has 5 cases for ega=37 then I would like to see a label with 5.
Also it would be great to have a reference line in every row, that has a different equation for every ega.

Hope someone can help me with this….

Thank you in advance!

Eva
=====================
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: graph with lines and labels

Andy W
It would help if you provided a simplified set of your data, but here is a shot untested to do the count labels you ask for. See the COUNT aggregation variable and the second point element to draw the labels.

As for the equations for each line I'm not sure what you are asking. Maybe see the example labels at the end of lines in this blog post, https://andrewpwheeler.wordpress.com/2015/01/14/labeling-tricks-in-spss-plots/ for ideas.

***********************************************************.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=ageSBR COUNT()[name="COUNT"] MEDIAN(result)[name="MEDIAN_result"] ABE egawk
    MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  PAGE: begin(scale(1000px,2500px))  SOURCE: s=userSource(id("graphdataset"))
  DATA: ageSBR=col(source(s), name("ageSBR"))
  DATA: MEDIAN_result=col(source(s), name("MEDIAN_result"))
  DATA: COUNT=col(source(s), name("COUNT"))
  DATA: ABE=col(source(s), name("ABE"), unit.category())
  DATA: egawk=col(source(s), name("egawk"), unit.category())
  GUIDE: axis(dim(1), label("Age of the baby in hours at time of SBR measurement"))
  GUIDE: axis(dim(2), delta(50), label("Median Result of SBR level in mgr/L"))
  GUIDE: axis(dim(4), label("ega in weeks, egadob truncated"), opposite())
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("ABE signs following study definition"))
  SCALE: linear(dim(1), max(360))
  SCALE: linear(dim(2), max(800))
  SCALE: cat(aesthetic(aesthetic.color.interior), include("2", "1", "0"), sort.values("2", "1",
    "0"))
  ELEMENT: line(position(ageSBR*MEDIAN_result*1*egawk), color.interior(ABE), missing.interpolate())
  ELEMENT: point(position(ageSBR*MEDIAN_result*1*egawk), color.interior(ABE), missing.interpolate(), label(COUNT),
           transparency.interior(transparency."1"), transparency.exterior(transparency."1"))
  PAGE: end()
END GPL.
***********************************************************.
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/