Graphics Reference
In-Depth Information
Figure 11-3. Top: with free y scales; bottom: with free x and y scales
Discussion
Each row of subplots has its own yrange when free yscales are used; the same applies to
columns when free xscales are used.
It's not possible to directly set the range of each row or column, but you can control the ranges
by dropping unwanted data (to reduce the ranges), or by adding geom_blank() (to expand the
ranges).
See Also
See Making a Cleveland Dot Plot for an example of faceting with free scales and a discrete axis.
Changing the Text of Facet Labels
Problem
You want to change the text of facet labels.
Solution
Change the names of the factor levels ( Figure 11-4 ):
mpg2 <- mpg # Make a copy of the original data
# Rename 4 to 4wd, f to Front, r to Rear
levels(mpg2$drv)[levels(mpg2$drv) == "4" ] <- "4wd"
levels(mpg2$drv)[levels(mpg2$drv) == "f" ] <- "Front"
levels(mpg2$drv)[levels(mpg2$drv) == "r" ] <- "Rear"
# Plot the new data
ggplot(mpg2, aes(x = displ, y = hwy)) + geom_point() + facet_grid(drv ~ . )
Search WWH ::




Custom Search