16.9 More about the theme() function
The theme() allows a precise control of graphical parameters such as axis text, ticks and labels, or legend texts and labels, etc.
More details here
# Let's the project_long object from exercise 12, and plot boxplots
<- ggplot(data=project_long, aes(x=variable, y=value, color=expr_limits)) +
boxp geom_boxplot()
# Remove the legend title:
+ theme(legend.title=element_blank()) boxp
# Change font of legend text
+ theme(legend.title=element_blank(),
boxp legend.text = element_text(colour="red", size = 8, face = "bold"))
# Put legend on the top of the plot
+ theme(legend.title=element_blank(),
boxp legend.text = element_text(colour="red", size = 8, face = "bold"),
legend.position="top")
# Rotate x-axis labels
+ theme(legend.title=element_blank(),
boxp legend.text = element_text(colour="red", size = 8, face = "bold"),
legend.position="top",
axis.text.x = element_text(angle = 90))
# Add a color to the plot's background
+ theme(legend.title=element_blank(),
boxp legend.text = element_text(colour="red", size = 8, face = "bold"),
legend.position="top",
axis.text.x = element_text(angle = 90),
plot.background = element_rect(fill = "yellow"))