6–9 Jul 2026
Europe/Warsaw timezone

Reusing 'ggplot2' code: how to design better plot helper functions

7 Jul 2026, 11:10
20m
Talks (15-20 minutes) Talks

Speaker

Cynthia Huang (LMU Munich)

Description

Wrapping 'ggplot2' code into plot helper functions is a common way to make multiple versions of a custom plot without
copying and pasting the same code over and over again. Helper functions can replace long and complex 'ggplot2' code
chunks with just a single function call. However, if that single function is not designed carefully, the initial convenience can
often turn into frustration. While helper functions can reduce the amount of code needed to remake a complicated plot, they
often mask the underlying layered grammar of graphics, complicating further customisation and tweaking of the plot.
This talk addresses how to design effective 'ggplot2' plot helper functions that maximise reuse convenience whilst
preserving access to the elegant flexibility of layered plot composition. By studying existing 'ggplot2' extensions for
producing calendar plots, we identify a number of common pitfalls, including overly specific function arguments and hidden
data manipulations. Then, we discuss how to avoid these pitfalls and retain the benefits of 'ggplot2' by: separating data
preparation from plotting, utilising list arguments for customisation, and providing transparent documentation. We illustrate
these strategies using examples from the design of the 'ggtilecal' package, which provides helper functions for plotting
calendars using the geom_tile() geometry from ggplot2.

If you used AI tools or services to support the preparation of this submission, please state the name and reason for using each of them.

Used LLM to generate first draft of talk abstract based on blog post

Additional Material or Paper

https://cynthiahqy.quarto.pub/ggplot-helpers-melburn-ssa-2025/#/title-slide
https://www.cynthiahqy.com/posts/ggplot-helper-design/

Keywords: Please list up to 5 keywords to help us find the right session for your contribution. R package and function design, layered grammar of graphics, data visualisation, ggplot2 extensions
Virtual Option This submission is for onsite presentation only
Video Recording Video sharing is fine
The author(s) agree(s) to take responsibility and be accountable for the contents of the submission and is/are authorized to present it. Confirm
Interested in serving as reviewer? Cynthia.huang@lmu.de

Author

Cynthia Huang (LMU Munich)

Presentation materials

There are no materials yet.