The following approach relies on ArrayPlot
to generate an appropriately colored and scaled Raster
object. I then extract the data and specifications from this object (size, scale), and split the data up into rows, each one of which is used to generate a new Raster
object with the specifications obtained above, but appropriately resized. The objects obtained, i.e. the "rows" of the original ArrayPlot
are then re-combined using Column
to introduce spacing. The process is wrapped in a custom function called spacedArray
:
Clear[spacedArray]
spacedArray[data_?MatrixQ] := Block[
{values, rectangle, range},
{values, rectangle, range} = First@Cases[
ArrayPlot[data, Mesh -> True],
Raster[values_, rectangle_, range_] :> {values, rectangle, range},
Infinity
];
rectangle[[2, 2]] = rectangle[[2, 2]]/First@Dimensions[values];
Column[
Graphics[Raster[{#}, rectangle, range], ImageSize -> 1 -> 25] & /@ values
]
]
Here is the result on the original toy data:
spacedArray[Table[x*y, {x, 4}, {y, 20}]]

... and on a different data set:
spacedArray[Table[x*y, {x, 5}, {y, 10}]]

Notice that in the latter case the size of the cells is retained, although the overall size and aspect ratio of the plot changes substantially.
Vertical spacing can be controlled with appropriate options to Column
. Obviously, this solution is still missing the mesh lines: those could be extracted from ArrayPlot
as well as Line
objects (two sets of lines, for the horizontal and vertical mesh respectively), but that seems tedious. Perhaps direct construction from Graphics
primitives would be best at that point.
ArrayPlot
" - withArrayPlot
itself, no; you may need to fall back with usingRaster[]
. $\endgroup$ – J. M.'s ennui♦ Feb 1 '17 at 21:30