I would like to show tick marks in the center of each bar, but only include labels for every other date. In the past, for continuous data, I've done something like this:
ylabs = seq(0, 4000, 250)
ylabs[-(seq(1, 31, 4))] = ""
scale_y_continuous(breaks = seq(0, 4000, 250), labels = ylabs, limits = c(0, 4000))
This method is annoying, but I cannot figure out how to solve this using ggplot2 functions. My best guess is to adopt my method above as follows:
labels = as.character(unique(Daily.Events$DateOnly))
labels[-seq(from = 1, to = length(labels), by = 2)] = ""
and some how insert the custom labels in the scale_x_datetime() function below:
g = ggplot(Daily.Events, aes(DateOnly, Count))
g = g + geom_bar(stat = "identity", fill = "black")
g = g + scale_x_datetime(name = "Date",
breaks = date_breaks("1 days"),
labels = date_format(format = "%b %d"),
expand = c(0,0))
g = g + scale_y_continuous(name = "Daily Events")
g = g + theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1))
plot(g)
Can anyone offer a better solution? I appreciate any help and criticism provided!