How can I suppress the vertical gridlines in a ggplot2 plot while retaining the x-axis labels?
As code in comments does not display nicely, so I am posting this as an answer. You could do something like this and add labels manually with geom_text()
:
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()
)+
geom_text(aes(label = x, y = -.3))
The answers above will not work in ggplot2 version 0.9.2.1 and above. Fortunately, there is now an easier way to do this, as described in response to a different question: https://stackoverflow.com/a/8992102/800044.