Leland Wilkinson’s work ‘The Grammar of Graphics’ (2000) heralded a new era for data visualization systems. The proposed Grammar identified components of data visualizations (visual channels, coordinates, stats, scales, geometric marks, etc), and advocated for systems that would let users declare these components to specify familiar or new graph types. To varying extents, popular modern systems like Tableau, vega lite, observable plot, altair, plotnine, seaborn , (more?), and ggplot2 are all shaped by the Wilkinson’s Grammar.

The ggplot2 library in R, created by Hadley Wickham (2010), is an especially notable implementation of the ideas elaborated by Wilkinson. The ‘gg’ in the library’s name acknowledges that Wilkinson’s vision inspired the project which has been maintained and further developed for nearly two decades, enjoying great popularity because of its elegance, flexibility, and ease of use.

Within ggplot2 itself, a large swath of common chart types can be easily produced. And with some effort - virtually any chart type could be specified. The ggplot2 extension system (formalized around 2015) allowed ggplot2 users to ‘wrap up’ some of this effort so that it could be accessed and reused in a way consistent with the ggplot2 system. As a consequence, the number of ggplot2 extensions packages has exploded into an ecosystem.

In an effort to provide a foothold into the ecosystem, meta-resources like the ggplot2 extension gallery and awesome ggplot2 have been created. Additionally, the ggplot2 extenders club has held virtual meetings since 2022, and boasts a lively discussion forum. The group exists for exchanging resources and experiences and to expose common extension patterns, pitfalls, and pathways.

Complete plots:

In addition to using the grammatical extension points to create more grammatical components, ggplot2 is also used for providing interfaces that fully specify plots.

One pathway for doing this is using the autoplot() extension point. Using autoplot(), extenders can specify the for plot take outputs based on the class of the input object, contrasting with the typical data frame or tibble input for standard ggplots. Notable examples include tsibble’s autoplot method, and (I’ll make sure we have one more example)

Another popular direction for extension is to offer complete plot functions, where preserving the grammar is not a main consideration. In these cases, the grammatical components will hidden from the user, and the arguments exposed in the plotting function will be according to the preferences and priorities of the package author and their audience. Packages taking this approach with many function offerings include ggcharts, ggpubr and ??. These packages do tend to maintain consistency in argument offerings across functions, helping users orient themselves within the frameworks.

It is also common for packages that aim to serve specific domains to offer complete plot functions including ???

‘Everything else’ section

A final category for extension are plots that make grammar moves beyond what is on offer within base ggplot2. For example, gganimate offers families of function like the transition_*() and ease_*(), components which complement the core ggplot2 grammar. Also, patchwork’s powerful plot composition operators feel grammatical in their predictability and exists beyond the scope of ggplot2 itself. Other packages that sit in this space - which at one prize consistency and composibility, and which also take on capabilities beyond core ggplot2 functionality are ggiraph (offering interactivity), ggraph (a framework for network visualization), and ?? (looking for one more!)