I would like to include minor brakes in my chart such that the full date is printed at the beginning of every month, and days are marked just by a tick on the x axis. What I have right now does not retrieve errors but the output is not what I want, since there are no ticks for the days.
library(ggplot2)
df <- data.frame(date=as.Date(1:60,origin = "1970-01-01"),value=rnorm(60,4,3))
str(df)
ggplot()+
geom_line(data=df, aes(x=date, y=value))+
scale_x_date(date_breaks = 'month', date_minor_breaks = 'day')
session:
other attached packages:
[1] scales_0.4.0 cowplot_0.6.2 ggplot2_2.1.0 dplyr_0.5.0 zoo_1.7-13
This issue has been discussed in Formatting dates with scale_x_date in ggplot2 but I wonder if something changed in the meanwhile since if I follow the code that was suggested
scale_x_date(breaks = "1 month", minor_breaks = "1 week", labels=date_format("%B"))
I actually get an error
> ggplot()+
+ geom_line(data=df, aes(x=date, y=value))+
+ scale_x_date(breaks = "1 month", minor_breaks = "1 week", labels=date_format("%B"))
Error in strsplit(unitspec, " ") : non-character argument