On 2010-04-29 12:15, Halldór Björnsson wrote:
I am trying to plot a image where the x axis has the units of time.
When I issue the
image(x,y,z) command with x as a POSIXct object, it fails to put a
time stamp on the
x axis.
Instead I get a warning "Incompatible methods" warning and no dates on
my x axis.
This example shows my problem:
Rmat=t(matrix(data=rnorm(1:500),ncol=10,nrow=50))
tax=seq(ISOdate(2010,4,14,12,0,0), ISOdate(2010,4,19,00,0,0), by = "12
hours") ylevs=seq(100,5000,length=50)
image(tax,ylevs,Rmat)
This givies the warning:
In image.default(tax, zlevs, Rmat) :
Incompatible methods ("-.POSIXt", "Ops.difftime") for "-"
2: In is.vector(X) :
I don't get that warning. Are you doing something you're not
telling us? (I note that you have 'ylevs' in one place and 'zlevs'
in another).
This works for me (using your above definitions of Rmat, etc):
image(tax, ylevs, Rmat, xaxt = "n")
axis(1, at = as.numeric(tax), lab = weekdays(tax, TRUE))
-Peter Ehlers
Contrast the x axis result of image with that of plot
plot(tax,rnorm(length(tax)))
where the date-time shows stamps work fine.
How can I get image to behave (or is there a better function for the job?)
Sincerely
Halldór
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
Peter Ehlers
University of Calgary
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.