Consider the two following examples:
ggplot(mtcars, aes(x = wt, y = qsec))
geom_point()
facet_grid(cols = vars(vs), rows = vars(gear), scales = "free")
geom_vline(aes(xintercept = mean(wt)))
Notice how this produces the same values of xintercept
for geom_vline
in the same column, even with scales = "free"
as was explained in
We now get the xintercept
s displayed separately in each facets. However, now the labels of both faceting variables are above the graphs. How do I move them so that, like in the facet_grid
, one variable's labels are on top and one on the right? I tried using strip.position = c("top", "right")
in facet_wrap
, but that gives the following error:
Error in match.arg(strip.position, c("top", "bottom", "left", "right")) :
'arg' must be of length 1
So then how to do it?
CodePudding user response: