Skip to content
Prev 326922 / 398502 Next

image versus levelplot

Dear R users,

I'm currently using the Graphics package to display several hundred of 
matrix objects, using a layout and the image() function.
It works well except for large matrices (> 1000*1000) or for a large 
number of matrices (there is a limitation around 400 if I remember well)
To solve these issues, I move to the Matrix package which is much more 
efficient for large sparse matrix, and to the grid package for the plot 
(using image from Matrix)
However, the levelplot() is much more slow than the graphics image() 
function !!
Basically, with the image() from graphics, I'm able to plot 360 matrices 
in 30 sec, against more than 10 minutes with levelplot().
I would appreciate if anyone has some experience on that, and could give 
me some advice to efficiently use the grid package !?
Regards
Nicolas

 > i=1000
 > M1 <- Matrix(rnorm(i*i), ncol=i)
 > system.time(print(Matrix::image(M1)))
    user  system elapsed
  11.320   0.064  11.406
 > M2 <- matrix(rnorm(i*i), ncol=i)
 > system.time(image(as.matrix(M2)))
    user  system elapsed
   0.837   0.004   0.844