Graph for Two Multicategory Variables

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

Graph for Two Multicategory Variables

Brian Dates
I wonder if it's possible to use GPL to place two separate multiple-category
variables which share the same categories and and scale into one graph. I
already have graphs that combine multiple single categories for separate
variables, but am stymied about how to put multiple category variables
together. I'm doing this for a matched t-test, so splitting one variable
isn't possible unless I restructure the data, which I'm trying to avoid
because I have a number of other graphs which depend on the present
structure. I've attached a word document with the two variables I'm trying
to combine.

As always, thanks for any help you can provide.

Brian

Sample_Graph.docx
<http://spssx-discussion.1045642.n5.nabble.com/file/t341458/Sample_Graph.docx>  



--
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
Reply | Threaded
Open this post in threaded view
|

Re: Graph for Two Multicategory Variables

Jon Peck
Yes, you can do this with GPL.  However, you might want to try the STATS COMPARE SUBGROUPS extension command which does something like that although with a number of other features.  You can install it from the Extensions > Extension Hub menu if you don’t already have it, and it will appear on the Graphs menu.

On Mon, Nov 26, 2018 at 6:51 PM Brian Dates <[hidden email]> wrote:
I wonder if it's possible to use GPL to place two separate multiple-category
variables which share the same categories and and scale into one graph. I
already have graphs that combine multiple single categories for separate
variables, but am stymied about how to put multiple category variables
together. I'm doing this for a matched t-test, so splitting one variable
isn't possible unless I restructure the data, which I'm trying to avoid
because I have a number of other graphs which depend on the present
structure. I've attached a word document with the two variables I'm trying
to combine.

As always, thanks for any help you can provide.

Brian

Sample_Graph.docx
<http://spssx-discussion.1045642.n5.nabble.com/file/t341458/Sample_Graph.docx



--
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
--
Jon K Peck
[hidden email]

===================== 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 for Two Multicategory Variables

Andy W
In reply to this post by Brian Dates
If you just want to do a clustered bar chart this is actually easy via the
legacy graph commands. Below I show that and some other ways to do it via
GGRAPH.

*********************************************************************************************.
DATA LIST FREE / Cat (A1) V1 V2 (2F3.0).
BEGIN DATA
A 40 30
B 20 60
C 10 40
END DATA.
DATASET NAME Bars.


GRAPH /BAR(GROUPED)=MEAN(V1) MEAN(V2) BY Cat.

*GGRAPH code examples.

*Superimposed points.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Cat V1 V2
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: Cat=col(source(s), name("Cat"), unit.category())
  DATA: V1=col(source(s), name("V1"))
  DATA: V2=col(source(s), name("V2"))
  GUIDE: axis(dim(1), label("Cat"))
  GUIDE: axis(dim(2), label("Y Value"))
  SCALE: linear(dim(2), include(0))
  ELEMENT: point(position(Cat*V2), size(size."12"), shape("V2"),
color.interior("V2"))
  ELEMENT: point(position(Cat*V1), size(size."12"), shape("V1"),
color.interior("V1"))
END GPL.
*Might want to also dodge if many points are overlapping, see.
*https://andrewpwheeler.wordpress.com/2013/03/06/some-random-spss-graph-tips-shading-areas-under-curves-and-using-dodging-in-binned-dot-plots/.
*Would need to reshape though wide to long to do that.

*Dodged dot plot with connecting edge.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Cat MEAN(V1) MEAN(V2)
   TRANSFORM=VARSTOCASES(SUMMARY="MaxBar" INDEX="V")
  /GRAPHSPEC SOURCE=INLINE
  /FRAME INNER=YES.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: Cat=col(source(s), name("Cat"), unit.category())
  DATA: V=col(source(s), name("V"), unit.category())
  DATA: MaxBar=col(source(s), name("MaxBar"))
  TRANS: base = eval(0)
  COORD: rect(dim(1,2), cluster(3))
  GUIDE: axis(dim(1), label("Cat"))
  GUIDE: axis(dim(2), label("Y Value"))
  SCALE: linear(dim(2), include(0))
  ELEMENT: edge(position(V*(base + MaxBar)*Cat), color(V))
  ELEMENT: point(position(V*MaxBar*Cat), size(size."12"), shape(V),
color.interior(V))
END GPL.
*********************************************************************************************.



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