How to set all MatrixPlot result with fixed grid size?

If you specify the size of the padding around the plot explicitly, calculating the right size for the plot is simple:

piecePlot[piece_] := Module[{mat, padding = 20, gridSize = 30},
  mat = StringCases[StringSplit[piece, ","], {"X" -> 1, "." -> 0}];
  MatrixPlot[mat, Mesh -> All, FrameStyle -> Opacity[0], 
   FrameTicksStyle -> Opacity[1], FrameTicks -> All,
   ImagePadding -> padding, 
   ImageSize -> (gridSize*Reverse[Dimensions[mat]] + 2*padding)]]

Where the only real change from your version are the last two options: ImagePadding -> padding, ImageSize -> (gridSize*Reverse[Dimensions[mat]] + 2*padding). I've simplified the string->matrix conversion a little.

piecePlot /@ ("pieces" /. data) // Multicolumn

enter image description here

Tags:

Plotting