[R] Plot fn, xlim when x is a date. XXXX
murdoch.duncan at gmail.com
Sun Jul 17 15:23:18 CEST 2011
On 11-07-17 8:22 AM, Dan Abner wrote:
> Hello everyone,
> I have the following x variable:
> This works fine, however, I want to plot multiple years of data on separate
> plots by month. All years have all 12 months data except 2011; HOWEVER I
> need the x axis limits to remain the same. I tried using xlim=c(1,12) and
> that did not work.
> Can someone please advise?
You need to use dates as xlim values. They will vary from year to year
(January 2010 is a different date than January 2011), but it's
reasonably easy to compute the limits you want when you subset the
dates. For example
x <- as.Date(paste("1/",1:6,"/11", sep=""), "%d/%m/%y")
jan <- x
dec <- as.Date("1/12/11", "%d/%m/%y")
plot(x, 1:6, xlim=c(jan, dec))
> Thank you!
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help