From gregor.gorjanc at bfro.uni-lj.si  Thu Dec  7 22:19:11 2006
From: gregor.gorjanc at bfro.uni-lj.si (Gregor Gorjanc)
Date: Thu, 07 Dec 2006 22:19:11 +0100
Subject: [Rd] Matplot does not work with x being POSIXt class (PR#9412)
In-Reply-To: <p06230913c19e2e5798f1@[128.115.153.6]>
References: <20061207125601.00D2257349@slim.kubism.ku.dk>
	<p06230913c19e2e5798f1@[128.115.153.6]>
Message-ID: <4578854F.7010708@bfro.uni-lj.si>

Hi,

Don MacQueen wrote:
...
> At 1:56 PM +0100 12/7/06, gregor.gorjanc at bfro.uni-lj.si wrote:
>> Hi,
>>
>> Matplot works with x being Date class but not POSIXt. Here is the
>> example with R version 2.5.0 Under development (unstable) (2006-12-06
>> r40129)
>>
>> Example:
>>
>> x <- Sys.Date() - c(1:10)
>> y <- cbind(1:10, 10:1)
>> class(x)
>> ## [1] "Date"
>> matplot(x, y)
>>
>> x <- strptime(as.character(x), format="%Y-%m-%d")
>> ## [1] "POSIXt"  "POSIXlt"
>> matplot(x, y)
>> Error in matplot(x, y) : 'x' and 'y' must have only 1 or the same number
>> of columns
>>
>> Additionally, matplot with x being Date class does not use apropriate
>> annotation for x axis.
> 
> This is very easy to obtain:
> 
> # x is a Date object
> matplot(x,y,xaxt='n')
> axis.Date(1,x)
> 
> or
> 
> # x is a POSIXlt object
> matplot( as.POSIXct(x), y,xaxt='n')
> axis.POSIXct(1,x)
> 
> So easy, in fact, that I personally would not expect R core to spend
> time on it. One of the virtues of R is that the language is so rich that
> little tweaks like this are often very easy.

Thank you Peter and Don for these insights. I see that changes would be
far from trivial/tricky and as Don pointed out simple tweaks by the user
can solve this.

Thank you and sorry for inconvenience!

Best wishes, Gregor



[Rd] Matplot does not work with x being POSIXt class (PR#9412)
Gregor Gorjanc