2

I have an array with dimensions 32x32x1000. I want to image all the slices of this array using the image and apply functions. The 1000 pictures would be displayed as a 25x40 plot. However, I am able to visualize only the first slice.

Here is my code:

par(mfrow = c(25, 40))

data <- array(data = b, dim = c(32,32,2000))

apply(data, c(1,2), FUN = image)
jay.sf
  • 60,139
  • 8
  • 53
  • 110
geo12035
  • 21
  • 1

1 Answers1

0

Use apply along margin 3. Example:

op <- par(mfrow=c(2, 2))
apply(A, MARGIN=3L, image)
par(op)

enter image description here

You probably will run into figure margins too large issues, which refers to the "preview" plotting device, so you may want to try one of these remedies. Also visit help('par') on how to adjust some other graphical parameters such as mar=.


Data:

set.seed(42)
A <- replicate(4, matrix(runif(10*10), 10))
jay.sf
  • 60,139
  • 8
  • 53
  • 110