Introduction
R has powerful and aesthetic graphics capabilities. In this blog entry, you’ll learn how to add and change title and axis labels in R graphics created with ggplot.
Access Data and Libraries
Install ggplot if you have not already done so, and load ggplot2:
install.packages("ggplot")
library(ggplot2)
Now access the dataset warpbreaks:
warpbreaks
head(warpbreaks)
Standard Labels
Try the following R code:
boxplot.wool<-ggplot(warpbreaks, aes(x=wool, y=breaks)) + geom_boxplot(col="firebrick")
boxplot.wool
That’s not bad, but you might want to change the labeling. Perhaps you want to use sentence case for “wool” and “breaks.” Perhaps you also want to add a descriptor to this boxplot. Let’s try the following R code:
boxplot.wool + labs(title="Breaks by Wool Type", subtitle="From R's warpbreaks dataset", y="Breaks", x="Wool")
Here’s what you get:
That’s what you wanted.
BridgeText can help you with all of your statistical analysis needs.