r - How to make scale_x_date week start with Sunday -


i'm creating weekly time series chart, , week should start sunday. when specify scale_x_date(breaks = date_breaks('1 week')) grid line , labels start on monday, results looks off. how can force ggplot scale_x_date week start on sunday

this example of code

library(ggplot2) library(scales)  data.set <- structure(list(week.start = structure(c(15732, 15739,                            15746, 15753, 15760, 15767, 15774, 15781,                            15788, 15795, 15802, 15809 ), class =                            "date"), overtime.avg = c(2.8,                            2.85666666666667, 2.18333333333333,                            2.44666666666667, 2.04833333333333,                            2.45833333333333, 2.12833333333333,                            1.81666666666667, 1.82166666666667,                            1.54333333333333, 2.09166666666667,                            0.970833333333333)), .names =                            c("week.start", "overtime.avg"), row.names                            = 29733:29744, class = "data.frame")  ggplot(data = data.set,        aes(x = week.start,            y = overtime.avg)) +     geom_line() +     geom_point() +     scale_x_date(breaks = date_breaks("1 week"),                  labels = date_format(format = "%y-%m-%d")) 

one way use function seq() , provide own break points starting first sunday (used minimal value of week.start) , set by="week".

ggplot(data = data.set,aes(x = week.start,y = overtime.avg)) +   geom_line() +   geom_point() +   scale_x_date(breaks = seq(min(data.set$week.start),max(data.set$week.start),by="week"),                labels = date_format(format = "%y-%m-%d")) 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -