title: How can I suppress the vertical gridlines in a ggplot2 plot while retaining the x-axis labels?
body: <p>This is a follow-on from <a href="https://stackoverflow.com/questions/2678141/how-can-i-suppress-the-vertical-gridlines-in-a-ggplot2-plot">this question, in which I was trying to suppress the vertical gridlines</a>.</p>
  
  <p>The solution, as provided by learnr, was to add scale_x_continuous(breaks = NA), but this had the side effect of also suppressing the x-axis labels, as well.  I am totally happy to write the labels back in by hand, but it's not clear to me how to figure out where the labels should go.</p>
  
  <p>The other option is to suppress all gridlines (using opts( panel.grid.major = theme_blank()) or some such) and then drawing back in just the major horizontal gridlines.  Again, the problem here is how to figure out what the breaks are in the plot to supply to geom_hline().</p>
  
  <p>So, essentially, my options are:</p>
  
  <ol>
  <li>Suppress vertical gridlines and x-axis labels (using scale_x_continuous(breaks = NA) ) and add the x-axis labels back in.</li>
  <li>Suppress all gridlines (using opts( panel.grid.major = theme_blank()) ) and add the major horizontal gridlines back in using geom_hline().</li>
  </ol>
  
  <p>Here are the two options:</p>
  
  <pre><code>library(ggplot2)
  
  data &lt;- data.frame(x = 1:10, y = c(3,5,2,5,6,2,7,6,5,4))
  
  # suppressing vertical gridlines and x-axis labels
  # need to re-draw x-axis labels
  ggplot(data, aes(x, y)) +
    geom_bar(stat = 'identity') +
    scale_x_continuous(breaks = NA) +
    opts(
      panel.grid.major = theme_line(size = 0.5, colour = '#1391FF'),
      panel.grid.minor = theme_blank(),
      panel.background = theme_blank(),
      axis.ticks = theme_blank()
    )
  
  # suppressing all gridlines
  # need to re-draw horizontal gridlines, probably with geom_hbar() 
  ggplot(data, aes(x, y)) +
    geom_bar(stat = 'identity') +
    scale_x_continuous(breaks = NA) +
    opts(
      panel.grid.major = theme_blank(),
      panel.grid.minor = theme_blank(),
      panel.background = theme_blank(),
      axis.ticks = theme_blank()
    )
  </code></pre>