In the following example, how do I get the y-axis limits to scale according to the data in each panel?
mt <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) + geom_point()
Neither of these will do it:
mt + facet_grid(. ~ cyl, scales="free") mt + facet_grid(. ~ cyl, scales="free_y")
facet_grid() forms a matrix of panels defined by row and column faceting variables. It is most useful when you have two discrete variables, and all combinations of the variables exist in the data.
While facet_grid shows the labels at the margins of the facet plot, facet_wrap creates a label for each plot panel.
Faceting is the process that split the chart window in several small parts (a grid), and display a similar chart in each section. Each section usually shows the same graph for a specific group of the dataset. The result is usually called small multiple.
Perhaps it's because you have only one y axis, using your way. Did you try something like this?
mt + facet_grid(cyl ~ ., scales="free")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With