The “localisation” or “translation” of the ggplot2 grammar is not just a gimmick it also allows avoiding having one package clash with the other.
Like with ggplot2, one creates visualisations by layering figures (geometries) defined by aspects (aesthetics).
Similarly to ggplot2, axis of the visualisation can be modified with
gauge_* (scales in ggplot2).
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Petal.Width) ) + geom_point(aes(size = Sepal.Width)) + scale_color_viridis_c()
As in ggplot2, other aspects of the visualisation can be defined. Unlike ggplot2 though, whether these aspects are columns from the data or constants they can only be specified within
data(penguins, package = "palmerpenguins")
ggplot(penguins, aes(bill_length_mm, bill_depth_mm, color = island) ) + geom_point(aes(shape = island))
Where one might use the
group aesthetic in ggplot2 one will want to use
color in g2r; it’ll define both the colour and the group.
In order to stack bars, or place bars side-by-side, or jitter points one must use the
G2r also comes with the equivalent of ggplot2’s facets, here they are named
There is also a function to quickly draw plots based on the class of the object it receives:
Generally g2r functions accept data in the form of data.frames or tibbles but it will attempt to transform other objects to (generally) data.frames.