knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(ggplot2) library(ggx)
Faceting requires the optional parameter data
be given either the original dataset used in your ggplot()
call, or a vector of column names (the output of names({your dataset here})
).
It defaults to facet_wrap()
over facet_grid()
.
ggplot(data=iris, mapping=aes(x=Sepal.Length, y=Petal.Length, color=Species))+ ggtitle("Iris")+ geom_point()+ gg_("facet by Species", data = iris)
ggplot(data=iris, mapping=aes(x=Sepal.Length, y=Petal.Length, color=Species))+ ggtitle("Iris")+ geom_point()+ gg_("facet by Species vertical", data = iris)
ggplot(data=iris, mapping=aes(x=Sepal.Length, y=Petal.Length, color=Species))+ ggtitle("Iris")+ geom_point()+ gg_("facet by Species 2 cols", data = iris)
ggplot(data=iris, mapping=aes(x=Sepal.Length, y=Petal.Length, color=Species))+ ggtitle("Iris")+ geom_point()+ gg_("grid by Species and Petal.Width", data = iris)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.