Table of Contents
Fetching ...

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.

ggtime: A Grammar of Temporal Graphics

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.

Paper Structure

This paper contains 35 sections, 17 figures.

Figures (17)

  • Figure 1: A selection of components in the grammar-based temporal graphics system ggtime which can be combined to produce a variety of visualizations that preserve temporal semantics. The left box highlights how compositions of Scale, Position, and Coordinate components highlight different features of repeating patterns. Each of these components act independently, and can be combined with other components in ggtime and the wider ggplot2 ecosystem to produce a wide variety of temporal graphics.
  • Figure 2: Illustrative example of how subsets of chronons form granularities. In this graphic, 1 day chronons are mapped to weekly (7 days) and fortnightly (2 week) granularities. This figure is sourced from [1].
  • Figure 3: Incorrect lexicographical ordering of days of the week from lossy discretization of time series
  • Figure 4: Two distinct time series drawn as one series due to a missing group produces a 'saw tooth' appearance as observations are not unique
  • Figure 5: A data error where multiple values for the same time point also introduces the 'saw tooth' shape
  • ...and 12 more figures

Theorems & Definitions (4)

  • Definition 4.1
  • Definition 4.2
  • Definition 4.3
  • Definition 4.4