If the frame and tick labels are the same for each grid element, you can pre-process the input to specify different option values for FrameLabel
, FrameTicks
and ImagePadding
for border and internal elements:
ClearAll[processGrid]
processGrid[padding_: {{Scaled[.05], Scaled[.0025]}, {Scaled[.05], Scaled[.0025]}},
flabel_: {"x", "y"}, fticks_: {{Automatic, Automatic}, {Automatic, Automatic}}] =
Module[{dims = Dimensions @ #, p = padding[[1, 2]],
sft = Charting`ScaledFrameTicks[{Identity, Identity}]},
MapIndexed[Switch[#2,
{dims[[1]], 1}, Show[#, FrameTicks -> fticks, ImagePadding -> padding,
FrameLabel -> flabel],
{_, 1}, Show[#, FrameTicks -> ReplacePart[fticks, {2, 1} -> sft],
FrameLabel -> ReplacePart[flabel, {1} -> None],
ImagePadding -> ReplacePart[padding, {2, 1} -> p]],
{dims[[1]], _}, Show[#, FrameTicks -> ReplacePart[fticks, {1, 1} -> sft],
FrameLabel -> ReplacePart[flabel, {2} -> None],
ImagePadding -> ReplacePart[padding, {1, 1} -> p]],
{_, _}, Show[#, FrameTicks -> sft, FrameLabel -> None,
ImagePadding -> p]] &, #, {2}]] &;
Examples:
fig1 = Plot[Sin[z], {z, -2 Pi, 2 Pi}, Frame -> True,
FrameLabel -> {"x", "y"}, ImageSize -> Automatic -> {300, 200},
LabelStyle -> {Black, FontSize -> 14}, PlotStyle -> Red];
grid = ArrayReshape[{fig1}, {2, 2}, "Fixed"];
Grid[processGrid[][grid], Spacings -> {0, 0}]
Grid[processGrid[][ArrayReshape[{fig1}, {3, 2}, "Fixed"]], Spacings -> {0, 0}]
You can specify padding in printer points:
Grid[processGrid[{{60, 10}, {60, 10}}][
ArrayReshape[{fig1}, {2, 2}, "Fixed"]], Spacings -> {0, 0}]
dfr = Grid[{{fig, fig}, {fig, fig}} /. (ImagePadding -> 80) -> ImagePadding -> Automatic, Frame -> False]
$\endgroup$