Question

How can I change the placement of the labels of facet_grid() without switching the formula?

library(plyr)
library(ggplot2)

data = data.frame(id = 1:10, value = rnorm(100*10))
data = ddply(data, .(id), transform, obs = 1:100)

ggplot(data = data, aes(x = obs, y = value, color = factor(id))) + 
  geom_line() +
  facet_grid(id ~.)

In the following picture, I want the panel text to switch from the right to the top of the panel.

enter image description here

Was it helpful?

Solution

ggplot(data = data, aes(x = obs, y = value, color = factor(id))) + 
         geom_line() +
         facet_wrap( ~id, ncol=1)

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top