Graphics Reference
In-Depth Information
The two included themes are theme_grey() and theme_bw() , but it is also possible to create
your own.
You can set the base font family and size with either of the included themes (the default base
font family is Helvetica, and the default size is 12):
p + theme_grey(base_size = 16 , base_family = "Times" )
You can set the default theme for the current R session with theme_set() :
# Set default theme for current session
theme_set(theme_bw())
# This will use theme_bw()
p
# Reset the default theme back to theme_grey()
theme_set(theme_grey())
See Also
To modify a theme, see Changing the Appearance of Theme Elements .
To create your own themes, see Creating Your Own Themes .
See ?theme to see all the available theme properties.
Changing the Appearance of Theme Elements
Problem
You want to change the appearance of theme elements.
Solution
To modify a theme, add theme() with a corresponding element_ xx object. These include ele-
ment_line , element_rect , and element_text . The following code shows how to modify
many of the commonly used theme properties ( Figure 9-6 ):
library(gcookbook) # For the data set
# Base plot
p <- ggplot(heightweight, aes(x = ageYear, y = heightIn, colour = sex)) + geom_point()
# Options for the plotting area
p + theme(
Search WWH ::




Custom Search