[R] image() and nonsquare matrices

Robin Hankin r.hankin at noc.soton.ac.uk
Fri Jan 12 11:12:35 CET 2007


How do I draw non-square matrices with image() and get the axes right?


Try 1:

  a <- matrix(rnorm(100),20,5)
image(1:20,1:5,a,asp=1,xlab="label here")
# No good because the axes don't touch the image



Try 2:

image(1:20,1:5,a,asp=1,axes=F,xlab="label here")
axis(side=1,pos=0)
# No good because the x axis label is floating far from the x axis.



Try 3:
  image(1:20,1:5,a,asp=1,axes=F,xlab="",ylab="")
  axis(side=1,pos=0)
# No good because the x axis label is absent.


How to use image() with a non-square matrix and make axes and labels  
appear correctly?





--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743



More information about the R-help mailing list