The goal of this tutorial is to set a new default theme in order to avoid defining the theme in every individual plot.
# First we load the libraries
library(ggplot2)
# We know that the theme_grey is the standard for ggplot
ggplot(data = iris, aes(x = Petal.Width, y = Petal.Length, colour = Species)) +
geom_point()
# However we can define a new theme adding it at the end of the call
ggplot(data = iris, aes(x = Petal.Width, y = Petal.Length, colour = Species)) +
geom_point() + theme_bw()
# We can define a different default theme for future plots
theme_set(theme_dark())
# Now the theme without any extra input will be the one we defined
ggplot(data = iris, aes(x = Petal.Width, y = Petal.Length, colour = Species)) +
geom_point()
In this tutorial we have learnt how to define a new default theme. This could be very useful when we have a corporate theme and we want to make sure all plots follow the theme.