0

Is there any possibility to remove "f e d" levels from the first subplot and "c b a" from the second subplot using facet_wrap? In other words I want to have only "c b a" columns on first subplot and only "f e d" columns on the 2nd.

Example data.frame:

df <- data.frame(x = letters[1:6], gr = c(rep("kk", 3), rep("yy", 3)), v = 10:15) 

Plot call:

ggplot(data = df, aes(x = x, y = v)) +
  geom_col() +
  coord_flip() +
  facet_wrap(~gr, nrow = 2)

Current result

mt1022
  • 16,834
  • 5
  • 48
  • 71
knst4444
  • 88
  • 1
  • 4

1 Answers1

1

To avoid a fixed scale for your y-axis, simply add scales = "free_y" to your facet_wrap() command.

ggplot(data = df, aes(x = x, y = v)) +
  geom_col() +
  coord_flip() +
  facet_wrap(~gr, nrow = 2, scales = "free_y")
Dave
  • 960
  • 6
  • 13