plot <- ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
geom_point(aes(colour = Species)) +
facet_wrap(Species ~ ., scales = "free_y")
# Reversing the y-axis in the second panel. When providing a list of scales,
# NULL indicates to use the default, global scale
plot +
facetted_pos_scales(
y = list(NULL, scale_y_continuous(trans = "reverse"))
)
# Alternative for specifying scales with formula lists. The LHS can access
# columns in the plot's layout.
plot +
facetted_pos_scales(
y = list(
Species == "virginica" ~ scale_y_continuous(breaks = c(6, 7)),
Species == "versicolor" ~ scale_y_reverse()
)
)
Run the code above in your browser using DataLab