4

Possible Duplicate:
add “floating” axis labels in facet_wrap plot

I am creating a panel of time series charts in RExcel using ggplot2. I have seen in many examples that the default when using ggplot2 seems to be to put the x-axis labels at the bottom of each column, even if the column does not reach all the way to the bottom (eg a 3 by 3 sapce filled with 7 plots, so two blank spaces on the lower left but with x-axis labels repeating three times across the bottom, one for each column).

My code, however, produces x-axis labels only on the bottom of the columns that reach all the way to the bottom. I have been playing around with this for a while and did not see anyone else with the same problem - thanks for helping me out!

(I added a minimal reproducible example, which is where the image comes from as well http://docs.ggplot2.org/current/facet_wrap.html)

library(ggplot2)
library(hexbin)
d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
  xlim(0, 2) + stat_binhex(na.rm = TRUE) + theme(aspect.ratio = 1)
d + facet_wrap(~ color)

enter image description here

Thank you! Please let me know if my question was not clear or if I can provide any additional info that may be of use.

Community
  • 1
  • 1
overflowname
  • 1,993
  • 3
  • 13
  • 12
  • You have the labels and don't want them? Or do you not have the labels and you _do_ want them? I can't tell because your code isn't reproducible. – joran Jun 22 '12 at 20:28
  • I don't have the labels and I want them - so sorry about the code... I can't give out the data... Thanks so much! – overflowname Jun 22 '12 at 20:52
  • 1
    I can't recall exactly, but I think it used to do that and folks complained about it, so it was changed. Off the top of my head, try "scales = "free_x"`, but that probably isn't ideal. – joran Jun 22 '12 at 21:04
  • 2
    Thanks so much joran! That definitely puts labels on all the graphs. And just in case someone lurking out there knows, I'll ask: is there a way to put lables only at the bottom of each column? I currently have 43 graphs arranged in a 9 by 5 grid, so there are two empty spaces. Ideally I would want to have an x-scale at the bottom of each column, but not for each individual graph. – overflowname Jun 25 '12 at 13:08
  • 1
    We are lurking and hoping someone might come up with an answer. – Roman Luštrik Nov 09 '12 at 16:34
  • 1
    As a workaround you could try `as.table = FALSE` as argument for `facet_wrap`. But this will reverse the order of panels. – Sven Hohenstein Nov 09 '12 at 19:57
  • It seems it existed in early versions of ggplot2 and was removed. I'm wondering if axes for uneven facet_wrap plots are such a desirable feature? There is a workaround in [this answer](http://stackoverflow.com/a/13316126/2641825) marked as duplicate. Comments there also suggest introducing a [ggplot2 feature](https://github.com/hadley/ggplot2/labels/feature), but 2 years later it seems there has been no follow-up. – Paul Rougieux Apr 08 '16 at 10:14

0 Answers0