ggtime: A Grammar of Temporal Graphics
Cynthia A. Huang, Mitchell O'Hara-Wild, Rob J. Hyndman, Matthew Kay
TL;DR
The paper tackles the challenge of faithfully visualizing time-oriented data by formalizing temporal semantics and introducing a grammar-based system, ggtime, as an extension to ggplot2. It defines semantic validity, fluid navigation, and error friction as core design goals, and provides time-aware data structures (mixtime, tsibble) and grammar components (data, aesthetics, geometries, coordinates, scales) to preserve temporal semantics across linear and cyclical time. Key contributions include a time-aware layering of the Grammar of Graphics, new time-offset aesthetics, looped and calendar coordinates, and a path toward more robust representations of multigranularity and civil time effects, such as daylight saving time. The work enables more accurate, interpretable temporal graphics and offers a foundation for future expansion into additional geometries, time-based statistics, and calendar-aware faceting, while emphasizing interoperability with broader semantic visualization systems.
Abstract
Visualizing changes over time is fundamental to learning from the past and anticipating the future. However, temporal semantics can be complicated, and existing visualization tools often struggle to accurately represent these complexities. It is common to use bespoke plot helper functions designed to produce specific graphics, due to the absence of flexible general tools that respect temporal semantics. We address this problem by proposing a grammar of temporal graphics, and an associated software implementation, 'ggtime', that encodes temporal semantics into a declarative grammar for visualizing temporal data. The grammar introduces new composable elements that support visualization across linear, cyclical, quasi-cyclical, and other granularities; standardization of irregular durations; and alignment of time points across different granularities and time zones. It is designed for interoperability with other semantic variables, allowing navigation across the space of visualizations while preserving temporal semantics.
