cluster Function (GPL)

Syntax

cluster(<integer> ...)

<integer>. One or more integers indicating the variable or variables in the algebra along whose axis the clustering occurs.

Description

Clusters graphic elements along a specific axis. You can also cluster graphic elements on more than one axis in 3-D charts.

Examples

Figure 1. Example: Clustering on the first dimension in a 2-D coordinate system
COORD: rect(dim(1,2), cluster(3))
ELEMENT: interval(position(summary.mean(jobcat*salary*gender)), color(jobcat))

In this example, jobcat is clustered in gender. Compare the position of the numbers in dim() to the positions of the numbers in cluster(). In this case, the 1 in dim and 3 in cluster are the first numbers in their respective functions. Therefore, clustering occurs on dim(3) (gender), and dim(1) (jobcat) specifies the variable that defines the graphic elements in each cluster. If you removed the cluster function, the chart would look similar, but dim(3) would specify a paneling facet and dim(1) would be the x axis. The clustering collapses multiple panels into one, changing the way dimensions are displayed. For example, compare the following graphs.

SOURCE: s = userSource(id("Employeedata"))
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: linear(dim(2), include(0))
  GUIDE: axis(dim(2), label("Mean Salary"))
  GUIDE: axis(dim(3), label("Gender"))
  ELEMENT: interval(position(summary.mean(jobcat*salary*gender)), color(jobcat))
END GPL.
Figure 2. Clustered bar chart
Clustered bar chart
SOURCE: s = userSource(id("Employeedata"))
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"))
SCALE: linear(dim(2), include(0.0))
GUIDE: axis(dim(2), label("Mean Salary"))
GUIDE: axis(dim(1), label("Job Category"))
ELEMENT: interval(position(summary.mean(jobcat*salary*gender)))
Figure 3. Faceted bar chart
Faceted bar chart
Figure 4. Example: Clustering on the first dimension in a 3-D coordinate system
COORD: rect(dim(1,2,3), cluster(4,0,0))
ELEMENT: interval(position(summary.mean(jobcat*gender*salary*minority)),
                  color(jobcat))

In this example, jobcat is clustered in minority. The first parameter of cluster is 4. This indicates that the first variable (jobcat) in the algebra is clustered in the fourth variable (minority). As in the 2-D example, removing the cluster function would result in a paneled chart.

Figure 5. Example: Clustering on the second dimension in a 3-D coordinate system
COORD: rect(dim(1,2,3), cluster(0,4,0))
ELEMENT: interval(position(summary.mean(minority*jobcat*salary*gender)),
                  color(gender))

In this example, jobcat is clustered in gender. The first parameter of cluster is 0, which indicates that dim(1) (minority) is not affected by the clustering. The second parameter of cluster is 4. This indicates that the second variable (jobcat) in the algebra is clustered in the fourth variable (gender).