my data frame is z:
library(ggplot2); library(scales)
z <- structure(list(Month = structure(c(14975, 15095, 15156, 15187,
15248), class = "Date&q
The documentation at ?scale_x_date
mentions that it accepts all "typical" continuous scale arguments, including limits
:
library(scales)
ggplot(z, aes(Month, Value)) +
geom_bar(fill="orange",size=.3, stat="identity", position="identity") +
geom_smooth(data=z,aes(Month,Value,group=1), method="lm", size=2, color="navyblue") +
scale_x_date(date_breaks = "1 month",
labels=date_format("%b-%Y"),
limits = as.Date(c('2011-01-01','2013-01-01')))