ggproto is at the heart of the R package ggplot2. It implements a protype based OO system which blurs the lines between classes and instances. It is inspired by the proto package, but it has some important differences. Notably, it cleanly supports cross-package inheritance, and has faster performance. Knowledge of ggproto is essential if you want to add new primitives, like geoms or stats to ggplot2.
Questions tagged with ggproto may often involve adding new functionality involved in plotting, such as making new scales, geoms, stats, coords and facet systems, through the ggproto extension mechanism.
The ggplot2 package introduced an official extension mechanism for Stats, Geoms and Positions in other packages in version 2.0.0. Since then, Facets (2.2.0) and Coords (3.0.0) were added. At the core of this mechanism is the prototype based ggproto
class that define the parameters and methods with which different structures in ggplot2 are build.
Important introductions to the topic can be found here:
- The introducing ggproto paragraph of the extending ggplot2 chapter of the ggplot2 book.
- The extending ggplot2 vignette.
- The writing ggplot2 extensions chapter of the ggplot2 book.