Bar Chart with Mapped Aesthetics (GPL)

This example demonstrates how you can map a specific categorical value in the graph to a specific aesthetic value. In this case, "Female" bars are colored green in the resulting graph.

Figure 1. GPL for bar chart with mapped aesthetics
* Open sample file Employee Data.sav.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=jobcat gender salary
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: jobcat = col(source(s), name("jobcat"), unit.category())
  DATA: gender = col(source(s), name("gender"), unit.category())
  DATA: salary = col(source(s), name("salary"))
 COORD: rect(dim(1, 2), cluster(3))
  SCALE: cat(aesthetic(aesthetic.color), map(("f", color.green)))
  GUIDE: axis(dim(2), label("Mean Salary"))
  GUIDE: axis(dim(3), label("Job Category"))
  ELEMENT: interval(position(summary.mean(gender*salary*jobcat)),
                    color(gender))
END GPL.
Figure 2. Bar chart with mapped aesthetics
Bar chart with mapped aesthetics