I'm trying to put the finishing touches on a grid of figures and could use some help. I'm trying to keep the figures as clean as possible, so I only want frame ticks and labels on the edge figures. However, when I do this, the figures on the far left and right are shrunk relative to the middle ones. I'd love to know how to fix this.
Here's the code and output.
(*set up scaling of population sizes*)
iVals = {1/2, 2, 8, 16};
(create simulations )
Table[
Ne = 8i;
initialCount = Ne; (allele frequency = initialCount/(2 Ne) *)
tMax = 5;
nPops = 100;
driftMatrix[i] =
Table[
(each row is the distribuiton of p at given generation )
NestList[
RandomInteger[BinomialDistribution[2 Ne, #/(2 Ne)]] &,
initialCount, tMax + 1]/(2 Ne) // N, {i, nPops}] //
Transpose,
{i, iVals}];
(set up the bins)
binWidth = {0.05};
binBoundaries = Range[ 0 - binWidth/2, 1 + binWidth/2, binWidth];
bin = binWidth;
(choose which time steps to plot )
tSteps = 10;
tVals = Range[0, 5];
rowVals = tVals + 1;
(make the plots )
plots = Table[
Table[
xTicks = If[j == Max[rowVals], Range[0, 1, 0.25], None];
lTicks =
If[i == Min[iVals], {{10, Style["0.5", Smaller]}} , None];
rTicks =
If[i == Max[iVals], {{10, Style["0.5", Smaller]}} , None];
rFrame = If[i == Max[iVals], True , False];
Histogram[
driftMatrix[i][[j]], binBoundaries, "PDF",
PlotRange -> {{0, 1}, {0, 12}},
Frame -> {{True, rFrame}, {True, False}},
FrameTicks -> {
{lTicks, rTicks},
{xTicks, None }
},
AspectRatio -> 1/3
], {j, rowVals}], {i, iVals}] // Transpose;
(combine plots into a Grid)
xlabels =
Text[Style[#, Medium]] & /@ (Join[8*iVals, {"Generation"}]);
ylabels = Text[Style[#, Medium]] & /@ (tVals);
Show[
Labeled[
Grid[
Join[
{xlabels},
Transpose[
Join[Transpose[plots], {ylabels}]
]
], Spacings -> {1, 0}
],
{"Population Size", "Bin Frequency",
"Frequency of bw75 Allele"}, {Top, Left, Bottom},
RotateLabel -> True],
ImageSize -> 12*72
]
It's subtle, but if you look you'll see that the frame lines of the left and right most plots don't match up with the interior ones.



ImageSize -> 1 -> 160toHistogramgives what you need. – kglr Feb 11 '21 at 05:30