title: Force x-axis labels on facet_grid ggplot: x-axis labels differ per row
body: <p>I was so happy to find the greater part of a solution to my question in the post, <strong>"<a href="https://stackoverflow.com/questions/17661052/force-x-axis-text-on-for-all-facets-of-a-facet-grid-plot">Force X axis text on for all facets of a facet_grid plot</a>"</strong>.</p>
  
  <p>I'd like to create a graph to look somewhat like the OP Drew Steen's, except I have more than two rows of facets, and I'd like to make the x-axes labels different for each row.</p>
  
  <p>I made a super-hacky solution out of @baptiste's awesome answer (mostly because I am unfamiliar with the gtable package), and I'd like to know:</p>
  
  <ol>
  <li>If there is a more elegant solution than the mess I wrote below</li>
  <li>How to insert labels for the "Premium" (middle) row.</li>
  </ol>
  
  <p>Here is the code I adapted from @Drew Steen and @baptiste,</p>
  
  <pre><code>library(ggplot2)
  
  diamondSub &lt;-subset(diamonds, (cut=="Ideal" | cut=="Premium" | cut == "Very Good") &amp; (color=="E" | color=="I"))
  
  p&lt;- ggplot(diamondSub, aes(x=carat, y=price)) + 
    geom_blank()+ 
    geom_point() +
    scale_x_discrete(breaks=c(1, 2, 3, 4), labels=c("a", "b", "c", "d")) +
    facet_grid(cut~color, scales="free_x")
  p
  
  p2&lt;- ggplot(diamondSub, aes(x=carat, y=price)) + 
    geom_blank()+ 
    geom_point() +
    scale_x_discrete(breaks=c(1, 2, 3, 4), labels=c("f", "g", "h", "i")) +
    facet_grid(cut~color, scales="free_x")
  p2
  
  library(gtable)
  
  g &lt;- ggplotGrob(p)
  g2 &lt;- ggplotGrob(p2)
  
  # locate the panels
  panels &lt;- grep("panel", g$layout$name)
  panels2 &lt;- grep("panel", g2$layout$name)
  
  top &lt;- unique(g$layout$t[panels])
  top2 &lt;- unique(g2$layout$t[panels2])
  # intersperse a copy of the bottom axes
  all &lt;- gtable:::rbind_gtable(gtable:::rbind_gtable(g[seq.int(min(top)), ], 
                                                     g[max(top)+1,], "first"), 
                               g2[seq(min(top2)+1, nrow(g2)),], "first")
  grid.newpage()
  grid.draw(all)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/JmUgt.jpg" alt="see graph"> </p>