[Rd] Question about image() behavior

Duncan Murdoch murdoch at stats.uwo.ca
Wed Nov 25 21:57:19 CET 2009


On 25/11/2009 3:00 PM, Justin McGrath wrote:
> If the x vector has a gap, then image() fills in those spots using the z
> value of the nearest x value. I had expected it to just leave those spaces
> blank though.
>
> For example
> x=c(1:5,100:105)
> y=c(1:10)
> z=matrix(rnorm(100),10,10)
> image(x,y,z)
>
> I expected that to produce a figure with a wide vertical gap between x=5 and
> x=100.
>
> Is this the correct behavior? Could there be an option added to choose
> between these two behaviors? Either way, it should be stated in the
> documentation.


It's doing what is documented.  Giving uneven spacing to x values just 
says that the rectangles being coloured by the z values are not square.

If you want to leave blanks, then put in NA values for z.

For example,

x <- c(1:6, 100:105)
y <- 1:10
z <- matrix(rnorm(110), 11, 10)
z[6,] <- NA
image(x,y,z)

Duncan Murdoch



More information about the R-devel mailing list