Sub-layer modularity in the Grammar of Graphics

June Choe Speaker
University of Pennsylvania
Wednesday, Aug 9: 11:35 AM - 11:55 AM
Topic-Contributed Paper Session 
Metro Toronto Convention Centre 
Sub-layer modularity—the design of Layers as compositional, consisting of sub-elements like Stat and Geom—is a powerful construct in implementations of the Grammar of Graphics like R's ggplot2. It has clearly served the design and growth of ggplot2 well, spurring a rich extension ecosystem. However, users remain limited in exploiting this feature of the grammar in practice; an arrangement that is partly intentional (to shield the user from the implementational details) and partly accidental (Stat-Geom pairs in many layers are not always intuitive or decomposable). I argue that this is not an inevitable tradeoff with a user-centric design: with the right framing and tools, users can develop a mental model of sub-layer processes to do more with existing code, advancing the practice of statistical graphics, and data visualization more broadly. I introduce and showcase the R package ggtrace as firstly a pedagogical tool to this end, and secondly a unified functional interface to ggplot2 internals that also serves the goals of aspiring and even experienced developers.