Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 22nd, 2012  |  syntax: None  |  size: 0.72 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Getting image.default to use class-defined Axis functions?
  2. par(mfrow = 2)
  3. image(x=as.POSIXct(1:100, origin = "1970-1-1"), z= matrix(rnorm(100*100), 100))
  4. plot(x=as.POSIXct(1:100, origin = "1970-1-1"), (rnorm(100)))
  5.        
  6. set.seed(42)
  7. X <- as.POSIXct(1:100, origin = "1970-1-1")
  8. Z <- matrix(rnorm(100*100), 100)
  9. image(x = X, z = Z, axes = FALSE)
  10. axis(side = 2)
  11. axis.POSIXct(side = 1, x = X)
  12. box()
  13.        
  14. image(x = X, z = Z, axes = FALSE)
  15. axis(side = 2)
  16. Axis(x = X, side = 1)
  17. box()
  18.        
  19. Image <- function(x = seq(0, 1, length.out = nrow(z)),
  20.                   y = seq(0, 1, length.out = ncol(z)),
  21.                   z, ...) {
  22.     image(x = X, z = Z, ..., axes = FALSE)
  23.     Axis(x = y, side = 2, ...)
  24.     Axis(x = X, side = 1, ...)
  25.     box()
  26. }