32
I would like to be able to specify the first and last tick marks which appear in a plot produced by ggplot2, but an running into some problems. Here is some code.
#Produce a vector of days
dateVec <- seq(from = as.Date("2011-11-21"), to = as.Date("2012-11-23"), by = "days")
#Some random values
myData <- rnorm(length(dateVec))
# Plot it
qplot(dateVec, myData) +
scale_x_date(breaks = "4 weeks", limits = c(min(dateVec), max=max(dateVec))) +
theme(axis.text.x = element_text(size = 10, angle = 45, colour = "black",
vjust = 1, hjust = 1))
Notice that the minimum date in the date vector is 2011-11-21 and the maximum date is 2012-11-23 and that I have specified the limits of the plot. However, the plot seems extended by some amount.
Is there a way to force the first and last tick marks to correspond to the actual limits specified in scale_x_date?
Thanks!