Say I have the following data:
require(ggplot2)
set.seed(123)
data <- data.frame(x = sample(1:20, 100, replace = TRUE))
I want to create a dot plot of data$x
, so this is what I do:
ggplot(data, aes(x)) +
geom_dotplot(binwidth = 1) +
scale_x_continuous(breaks = seq(1, 20, 1)) +
scale_y_continuous(breaks = NULL)
Which gives me this:
I would like to get rid of those vertical grid lines, so I add theme(line = element_blank())
to my ggplot statement. The problem is that command also eliminates the tick marks, which I would like to keep. How can I hide the grid lines whilst keeping their respective ticks?
I would also like to know how I can change the grid lines so they'll be drawn every 1:20
, not at every 0.5 mark.
I've looked for those answers in ?title()
and ?geom_dotplot
, tried a couple of things, to no avail. Appreciate the help!