0

If the number of panels in the last row is different to the rows above, the x-axis labels are missing in a facet plot with ggplot2. How can I add these?

For example:

d <- ggplot(diamonds, aes(carat, price, colour=color))
d + geom_point() + facet_wrap(~ clarity, ncol=5)

gives:

enter image description here

where the carat labels are missing for columns 4 and 5.

user3460194
  • 511
  • 1
  • 4
  • 14
  • Add `, scales = "free"` to your `facet_wrap` – David Arenburg Aug 21 '14 at 15:54
  • Just so you know, if I recall correctly, there was a time when it would plot the "extra" x axes floating off in space as you described and that behavior was removed intentionally because folks didn't like it. – joran Aug 21 '14 at 15:56
  • [This](http://stackoverflow.com/questions/13297155/add-floating-axis-labels-in-facet-wrap-plot) question may be helpful. – tonytonov Aug 22 '14 at 06:14
  • @DavidArenburg: This adds labels to each panel, which is not what I was looking for. – user3460194 Aug 22 '14 at 09:34
  • @joran: That's interesting. To me it would be great to have it back as an option. – user3460194 Aug 22 '14 at 09:34
  • @tonytonov: Thanks for pointing to this question! Version 1 in the link did the trick! – user3460194 Aug 22 '14 at 09:35
  • You are welcome! You may now either post your solution and mark it as accepted, or leave the question as it is. In the latter case it is likely to be closed as a duplicate after a while. – tonytonov Aug 22 '14 at 10:21

0 Answers0