scale_x_date

98 views
Skip to first unread message

V N

unread,
May 18, 2012, 7:54:23 PM5/18/12
to ggp...@googlegroups.com
I am getting an error when I run the following code in R2.15.0/ggplot2 0.9.1 and R2.14.2/ggplot2 0.9.1.  Runs fine in R2.14.1/ggplot2 0.8.9.

require(ggplot2)

timescale <- seq(as.Date("01/01/09","%m/%d/%y"), length.out=12, by=7) 
data.all <- data.frame( 
    id = c(rep('111',12),rep('222',12),rep('333',12)), 
    week=c(timescale,timescale,timescale), 
    value=c(rnorm(12,15,3),rnorm(12,30,5),rnorm(12,20,5))
)

p <- ggplot(data.all, aes(x=week, y=value, group=id, colour=id)) + 
    scale_x_date(format="%m/%d/%y", major="28 days", minor="7 days") + geom_line(size=1.05)

Error:

Error in continuous_scale(aesthetics, "date", identity, breaks = breaks,  : 
  unused argument(s) (format = "%m/%d/%y", major = "28 days", minor = "7 days")

Any help would be greatly appreciated.  Thanks.


V N

unread,
May 18, 2012, 9:43:48 PM5/18/12
to ggp...@googlegroups.com
Never mind.  I just saw this document --  http://cloud.github.com/downloads/hadley/ggplot2/guide-col.pdf

Dennis Murphy

unread,
May 18, 2012, 9:44:29 PM5/18/12
to V N, ggp...@googlegroups.com
Hi:

Try this:

library('scales')
ggplot(data.all, aes(x=week, y=value, group=id, colour=id)) +
scale_x_date(breaks = date_breaks("28 days"),
labels = date_format ("%m/%d/%y"),
minor_breaks = "7 days") +
geom_line(size=1.05)
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
Reply all
Reply to author
Forward
0 new messages