GPL code to draw line plot?

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

GPL code to draw line plot?

Zuluaga, Juan
Hello SPSS people,
May I ask another question about GPL code?
I would like to draw two plots of plots, variations of
http://web.stcloudstate.edu/jzuluaga/spss/profileplot.png

or
|           *
|  ----*------
|  *
|
+----------------
  Fall    Spring

In first plot, from a database that looks like

MAPMathFall MAPMathSpring group
2           7             A
4           6             B

So blue (asterisk) line represents the "growth" of that first individual, as a line that joins two points in time.
And second line ----  is the flatter growth of that second individual.
There is a line for every row in the dataset


Wilkinson's book (314) has an example on page 314, and from there I copied the code -- trouble is, the string() command does not work.


GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=LetterGroup MapMathFall MapMathSpring Spring
   MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: LetterGroup=col(source(s), name("group"), unit.category())
  DATA: MapMathFall=col(source(s), name("MAPMathFall"))
  DATA: Fall=string("Fall")
  DATA: MapMathSpring=col(source(s), name("MAPMathSpring"))
  DATA: Spring=string("Spring")
  DATA: id=col(source(s), name("Student"), unit.category())
  ELEMENT: line(position(MAPMathFall*Fall+ MAPMathSpring*Spring),color(LetterGroup))
END GPL.


Now, for the second plot, I would like the line for a group to go from average Fall score for that group, to average Spring Score for that group -- a bit similar to an interaction plot.
Dataset again is
MAPMathFall MAPMATHSpring Group
2     7     A
4     6     B
2     4     A
4     4     B

Two lines, line for A goes in height from (2+2)/2=2 to (7+4)/2=5.5,
line for B goes in height from 4 to 5.

=====================
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: GPL code to draw line plot?

ViAnn Beadle
The syntax of GPL doesn't quite match Lee's syntax. Use the unit.category()
function to specify that a variable is categorical.

Second, you can use parallel coordinates to do profile plots. Go to Help >
GPL Reference > GPL Statement and Function Reference > GPL Statements >
COORD Statement (GPL) > GPL Coordinate Types and you'll see a complete
example.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Zuluaga, Juan
Sent: Wednesday, May 18, 2011 4:26 PM
To: [hidden email]
Subject: GPL code to draw line plot?

Hello SPSS people,
May I ask another question about GPL code?
I would like to draw two plots of plots, variations of
http://web.stcloudstate.edu/jzuluaga/spss/profileplot.png

or
|           *
|  ----*------
|  *
|
+----------------
  Fall    Spring

In first plot, from a database that looks like

MAPMathFall MAPMathSpring group
2           7             A
4           6             B

So blue (asterisk) line represents the "growth" of that first individual, as
a line that joins two points in time.
And second line ----  is the flatter growth of that second individual.
There is a line for every row in the dataset


Wilkinson's book (314) has an example on page 314, and from there I copied
the code -- trouble is, the string() command does not work.


GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=LetterGroup MapMathFall
MapMathSpring Spring
   MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: LetterGroup=col(source(s), name("group"), unit.category())
  DATA: MapMathFall=col(source(s), name("MAPMathFall"))
  DATA: Fall=string("Fall")
  DATA: MapMathSpring=col(source(s), name("MAPMathSpring"))
  DATA: Spring=string("Spring")
  DATA: id=col(source(s), name("Student"), unit.category())
  ELEMENT: line(position(MAPMathFall*Fall+
MAPMathSpring*Spring),color(LetterGroup))
END GPL.


Now, for the second plot, I would like the line for a group to go from
average Fall score for that group, to average Spring Score for that group --
a bit similar to an interaction plot.
Dataset again is
MAPMathFall MAPMATHSpring Group
2     7     A
4     6     B
2     4     A
4     4     B

Two lines, line for A goes in height from (2+2)/2=2 to (7+4)/2=5.5, line for
B goes in height from 4 to 5.

=====================
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: GPL code to draw line plot?

Zuluaga, Juan
In reply to this post by Zuluaga, Juan
Dear SPSS people,
Would you know how to align a parallel plot?
as you can see in
http://web.stcloudstate.edu/jzuluaga/spss/parallel1.png
the two axes are not aligned.
Notice how the SCALE lines have both origin and max. I also tried with min, to no avail.
SPSS is version 17, Windows.

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=group MAPReadingFall MAPReadingSpring
   MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: group=col(source(s), name("group"), unit.category())
  DATA: MAPReadingFall=col(source(s), name("MAPReadingFall"))
  DATA: MAPReadingSpring=col(source(s), name("MAPReadingSpring"))
  DATA: id=col(source(s), name("Student"), unit.category())
  TRANS: caseid=index()
  COORD: parallel()
  SCALE: linear(dim(1),origin(160),max(300))
  SCALE: linear(dim(2),origin(160),max(300))
  ELEMENT: line(position(MAPReadingFall*MAPReadingSpring),split(caseid), color(group))
END GPL.

=====================
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: GPL code to draw line plot?

ViAnn Beadle
Edit the chart, click, on the axis line and set the top and bottom y
margins. This is known "feature" in 17 but I think has been fixed in 18 or
19?

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Zuluaga, Juan
Sent: Tuesday, May 24, 2011 10:03 AM
To: [hidden email]
Subject: Re: GPL code to draw line plot?

Dear SPSS people,
Would you know how to align a parallel plot?
as you can see in
http://web.stcloudstate.edu/jzuluaga/spss/parallel1.png
the two axes are not aligned.
Notice how the SCALE lines have both origin and max. I also tried with min,
to no avail.
SPSS is version 17, Windows.

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=group MAPReadingFall
MAPReadingSpring
   MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: group=col(source(s), name("group"), unit.category())
  DATA: MAPReadingFall=col(source(s), name("MAPReadingFall"))
  DATA: MAPReadingSpring=col(source(s), name("MAPReadingSpring"))
  DATA: id=col(source(s), name("Student"), unit.category())
  TRANS: caseid=index()
  COORD: parallel()
  SCALE: linear(dim(1),origin(160),max(300))
  SCALE: linear(dim(2),origin(160),max(300))
  ELEMENT: line(position(MAPReadingFall*MAPReadingSpring),split(caseid),
color(group)) END GPL.

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