theme_bw() , theme_minimal(), theme_classic() …
What are ggplot themes?
In R , ggplot2
is a popular data visualization library which can create static and interactive plots. A key features of ggplot2
is the ability to customize the look and feel of a plot through themes.
A theme in ggplot2
is a set of pre-defined options that control the visual elements of a plot, such as the font size, axis labels, and background color. There are several built-in themes available in ggplot2
, such as theme_gray()
, theme_classic()
, and theme_bw()
, and more …
Setting the themes
Themes can be applied to a plot using the +
operator , or they can be set prior to building the plot as shown below,
theme_set(theme_bw())
another way of setting a theme is attaching it to the plot with the + operator:
p <- CarSalesData %>% ggplot()+
geom_point(mapping = aes(x = Vehicle.Age.Yrs , y = Mileage , col = Vehicle.Type )) +
labs(title = "Theme_minimal")
p + theme_minimal()theme_minimal()