Graphics Reference
In-Depth Information
See Also
The options for modifying themes are listed in Changing the Appearance of Theme Elements .
Hiding Grid Lines
Problem
You want to hide the grid lines in a plot.
Solution
The major grid lines (those that align with the tick marks) are controlled with pan-
el.grid.major . The minor grid lines (the ones between the major lines) are controlled with
panel.grid.minor . This will hide them both, as shown in Figure 9-8 (left):
library(gcookbook) # For the data set
p <- ggplot(heightweight, aes(x = ageYear, y = heightIn)) + geom_point()
p + theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank())
Figure 9-8. Left: no grid lines; middle: no vertical lines; right: no horizontal lines
Discussion
It's possible to hide just the vertical or horizontal grid lines, as shown in the middle and
righthand graphs in Figure 9-8 , with panel.grid.major.x , panel.grid.major.y , pan-
el.grid.minor.x , and panel.grid.minor.y :
Search WWH ::




Custom Search