Overlaying group histograms

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

Overlaying group histograms

Ranjana Dutta
This may be a very simple question for people on this forum, but somehow I am stumped! I am looking at group differences on GPA for 3 groups of students. Is it possible to get superimposed histograms of the three groups in SPSS Graphs?
Reply | Threaded
Open this post in threaded view
|

Re: Overlaying group histograms

ViAnn Beadle

Yes. I assume that your data are arranged so that you have a single measurement variable and a nominal grouping variable (the usual long organization of data).  Here’s an example using the employee.sav file in the sample files. Note that you need to change the transparency of the bars since they will be overlaid on top of each other within the x axis bin value:

 

GGRAPH

  /GRAPHDATASET NAME="graphdataset" VARIABLES=salary gender MISSING=LISTWISE REPORTMISSING=NO

  /GRAPHSPEC SOURCE=INLINE.

BEGIN GPL

  SOURCE: s=userSource(id("graphdataset"))

  DATA: salary=col(source(s), name("salary"))

  DATA: gender=col(source(s), name("gender"), unit.category())

  GUIDE: axis(dim(1), label("Current Salary"))

  GUIDE: axis(dim(2), label("Frequency"))

  GUIDE: legend(aesthetic(aesthetic.color.interior), label("Gender"))

  SCALE: cat(aesthetic(aesthetic.color.interior), include("f", "m"))

  ELEMENT: interval(position(summary.count(bin.rect(salary))), color.interior(gender),

    shape.interior(shape.square), transparency(transparency."0.5"))

END GPL.

 

50% transparency works well with 2 groups, but I’d recommend bumping it up to 75% with three.

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Ranjana Dutta
Sent: Friday, November 09, 2012 3:03 PM
To: [hidden email]
Subject: Overlaying group histograms

 

This may be a very simple question for people on this forum, but somehow I am stumped! I am looking at group differences on GPA for 3 groups of students. Is it possible to get superimposed histograms of the three groups in SPSS Graphs?

Reply | Threaded
Open this post in threaded view
|

Re: Overlaying group histograms

Jon K Peck
You might also want to consider a population pyramid, which you can do directly from the Chart Builder under histograms.

You can generate the GPL for ViAnn's example from the Chart Builder by adding a grouping variable to the histogram display, but you would still need to paste the syntax and add the transparency specification.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        ViAnn Beadle <[hidden email]>
To:        [hidden email],
Date:        11/09/2012 03:25 PM
Subject:        Re: [SPSSX-L] Overlaying group histograms
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Yes. I assume that your data are arranged so that you have a single measurement variable and a nominal grouping variable (the usual long organization of data).  Here’s an example using the employee.sav file in the sample files. Note that you need to change the transparency of the bars since they will be overlaid on top of each other within the x axis bin value:
 
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=salary gender MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: salary=col(source(s), name("salary"))
  DATA: gender=col(source(s), name("gender"), unit.category())
  GUIDE: axis(dim(1), label("Current Salary"))
  GUIDE: axis(dim(2), label("Frequency"))
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("Gender"))
  SCALE: cat(aesthetic(aesthetic.color.interior), include("f", "m"))
  ELEMENT: interval(position(summary.count(bin.rect(salary))), color.interior(gender),
    shape.interior(shape.square), transparency(transparency."0.5"))
END GPL.
 
50% transparency works well with 2 groups, but I’d recommend bumping it up to 75% with three.
 
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Ranjana Dutta
Sent:
Friday, November 09, 2012 3:03 PM
To:
[hidden email]
Subject:
Overlaying group histograms

 
This may be a very simple question for people on this forum, but somehow I am stumped! I am looking at group differences on GPA for 3 groups of students. Is it possible to get superimposed histograms of the three groups in SPSS Graphs?