6

When trying to plot something like this:

library(ggplot2)
d <- ggplot(diamonds, aes(carat, price)) +
  xlim(0, 2) + geom_point()
d + facet_wrap(~ color)

You will notice that the x-axis labels only show up for the first column. I would like them to repeate on the second and third column. Is this possible?

If on the facet_wrap I use the option scales="free",

d + facet_wrap(~ color, scales="free")

then i get x-axis labels on all plots, which I also don't want. I want only labels in the bottom row repeating across columns

If the number of panels to be plot is such, that all columns have the same number of plots, the axis gets repeated in the way I want. But I can't always have the right number of panels for that.

zelite
  • 1,478
  • 16
  • 37
  • `scales` take only 4 values : `fixed`, `free`, `free_x` and `free_y`. So, I don't think it's possible to do what you require. – Arun May 14 '13 at 08:51
  • 3
    Is [this](http://stackoverflow.com/questions/13297155/add-floating-axis-labels-in-facet-wrap-plot/13316126#13316126) what you need? – Julius Vainora May 14 '13 at 08:58
  • that works. I tought there would be a simpler way, but your function works quite well, and I like that I can costumize `pos`. – zelite May 14 '13 at 09:22

1 Answers1

1

With version 2.2.0 of ggplot this problem is fixed. see https://www.rstats-tips.net/2016/11/ggplot2-x-axis-scale-now-available-on-all-facet-columns/

enter image description here

JerryWho
  • 3,060
  • 6
  • 27
  • 49