Mapping 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 mapping aesthetics
* Open sample file Employee Data.sav.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=salary jobcat gender
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: salary = col(source(s), name("salary"))
  DATA: jobcat = col(source(s), name("jobcat"), unit.category())
  DATA: gender = col(source(s), name("gender"), unit.category())
  COORD: rect(dim(1, 2), cluster(3))
  SCALE: cat(aesthetic(aesthetic.color), map(("Female", 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. Graph with mapped aesthetics
Graph with mapped aesthetics