How Coordinates and the GPL Algebra Interact

The algebra defines the dimensions of the graph. Each crossing results in an additional dimension. Thus, gender*jobcat*salary specifies three dimensions. How these dimensions are drawn depends on the coordinate system and any functions that may modify the coordinate system.

Some examples may clarify these concepts. The relevant GPL statements are extracted from the full specification.

1-D Graph

COORD: rect(dim(1))
ELEMENT: point(position(salary))

Full Specification

SOURCE: s = userSource(id("Employeedata"))
DATA: salary = col(source(s), name("salary"))
COORD: rect(dim(1))
GUIDE: axis(dim(1), label("Salary"))
ELEMENT: point(position(salary))
Figure 1. Simple 1-D scatterplot
Simple 1-D scatterplot
  • The coordinate system is explicitly set to one-dimensional, and only one variable appears in the algebra.
  • The variable is plotted on one dimension.

2-D Graph

ELEMENT: point(position(salbegin*salary))

Full Specification

SOURCE: s = userSource(id("Employeedata"))
DATA: salbegin=col(source(s), name("salbegin"))
DATA: salary=col(source(s), name("salary"))
GUIDE: axis(dim(2), label("Current Salary"))
GUIDE: axis(dim(1), label("Beginning Salary"))
ELEMENT: point(position(salbegin*salary))
Figure 2. Simple 2-D scatterplot
Simple 2-D scatterplot
  • No coordinate system is specified, so it is assumed to be 2-D rectangular.
  • The two crossed variables are plotted against each other.

Another 2-D Graph

ELEMENT: interval(position(summary.count(jobcat)))

Full Specification

SOURCE: s = userSource(id("Employeedata"))
DATA: jobcat=col(source(s), name("jobcat"), unit.category())
SCALE: linear(dim(2), include(0))
GUIDE: axis(dim(2), label("Count"))
GUIDE: axis(dim(1), label("Job Category"))
ELEMENT: interval(position(summary.count(jobcat)))
Figure 3. Simple 2-D bar chart of counts
Simple 2-D bar chart of counts
  • No coordinate system is specified, so it is assumed to be 2-D rectangular.
  • Although there is only one variable in the specification, another for the result of the count statistic is implied (percent statistics behave similarly). The algebra could have been written as jobcat*1.
  • The variable and the result of the statistic are plotted.

A Faceted (Paneled) 2-D Graph

ELEMENT: interval(position(summary.mean(jobcat*salary*gender)))

Full Specification

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))
GUIDE: axis(dim(3), label("Gender"))
GUIDE: axis(dim(2), label("Mean Salary"))
GUIDE: axis(dim(1), label("Job Category"))
ELEMENT: interval(position(summary.mean(jobcat*salary*gender)))
Figure 4. Faceted 2-D bar chart
Faceted 2-D bar chart
  • No coordinate system is specified, so it is assumed to be 2-D rectangular.
  • There are three variables in the algebra, but only two dimensions. The last variable is used for faceting (also known as paneling).
  • The second dimension variable in a 2-D chart is the analysis variable. That is, it is the variable on which the statistic is calculated.
  • The first variable is plotted against the result of the summary statistic calculated on the second variable for each category in the faceting variable.

A Faceted (Paneled) 2-D Graph with Nested Categories

ELEMENT: interval(position(summary.mean(jobcat/gender*salary)))

Full Specification

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.1), label("Job Category"))
GUIDE: axis(dim(1), label("Gender"))
ELEMENT: interval(position(summary.mean(jobcat/gender*salary)))
Figure 5. Faceted 2-D bar chart with nested categories
Faceted 2-D bar chart with nested categories
  • This example is the same as the previous paneled example, except for the algebra.
  • The second dimension variable is the same as in the previous example. Therefore, it is the variable on which the statistic is calculated.
  • jobcat is nested in gender. Nesting always results in faceting, regardless of the available dimensions.
  • With nested categories, only those combinations of categories that occur in the data are shown in the graph. In this case, there is no bar for Female and Custodial in the graph, because there is no case with this combination of categories in the data. Compare this result to the previous example that created facets by crossing categorical variables.

A 3-D Graph

COORD: rect(dim(1,2,3))
ELEMENT: interval(position(summary.mean(jobcat*gender*salary)))

Full Specification

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"))
COORD: rect(dim(1,2,3))
SCALE: linear(dim(3), include(0))
GUIDE: axis(dim(3), label("Mean Salary"))
GUIDE: axis(dim(2), label("Gender"))
GUIDE: axis(dim(1), label("Job Category"))
ELEMENT: interval(position(summary.mean(jobcat*gender*salary)))
Figure 6. 3-D bar chart
3-D bar chart
  • The coordinate system is explicitly set to three-dimensional, and there are three variables in the algebra.
  • The three variables are plotted on the available dimensions.
  • The third dimension variable in a 3-D chart is the analysis variable. This differs from the 2-D chart in which the second dimension variable is the analysis variable.

A Clustered Graph

COORD: rect(dim(1,2), cluster(3))
ELEMENT: interval(position(summary.mean(gender*salary*jobcat)), color(gender))

Full Specification

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"))
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))
Figure 7. Clustered 2-D bar chart
Clustered 2-D bar chart
  • The coordinate system is explicitly set to two-dimensional, but it is modified by the cluster function.
  • The cluster function indicates that clustering occurs along dim(3), which is the dimension associated with jobcat because it is the third variable in the algebra.
  • The variable in dim(1) identifies the variable whose values determine the bars in each cluster. This is gender.
  • Although the coordinate system was modified, this is still a 2-D chart. Therefore, the analysis variable is still the second dimension variable.
  • The variables are plotted using the modified coordinate system. Note that the graph would be a paneled graph if you removed the cluster function. The charts would look similar and show the same results, but their coordinate systems would differ. Refer back to the paneled 2-D graph to see the difference.