# Force Plot Area size to be equal excluding axes

I have two plots, both with the exact same formatting (frame, text style, etc.). One of them has 2-digit values for the y axes, the other has scientific notation because the value are large. In addition, they can have a different number of lines for the Axes labels.

I set ImageSize->250, and the bounding boxes of the images (plots) are set to 250 pixels. Cool. Normally this is fine. However, when the two plots have different axes or labels, this results in:

What I want is the actual plot area to be the same, without manually adjusting ImageSize for the 2nd image:

Notice how the labels make the bounding box grow outward, but the plot area size is the same (also in width, just not shown). In this particular example, the right image has ImageSize->280.

Does anyone know how to set the plot area size rather than the ImageSize?

EDIT 1:

@anononononomous mentioned a function to get the max padding size, and then apply it to each plot. This is getting closer! But it's clipping the FrameLabel:

(Also, sorry for adding more data, it doesn't change the question though).

-
I believe GraphicsGrid will equalize the heights. –  David Carraher Dec 14 '12 at 20:10
I think, if you use the same values for the options ImageSize and ImagePadding in both plots, you should get the same plot area size in both. –  kguler Dec 14 '12 at 20:44
@NasserM.Abbasi Correct, DavidCarraher's solution is not sufficient. kguler, That's getting closer. If you pad the images enough, then you can get the plot area sizes eqaul. However, you end up with a lot of extra space between images (if they're in a list, for example). –  dthor Dec 14 '12 at 20:55

With fingers crossed that someone will come up with a less manual method, I suggest the following completely manual approach: use the same setting for ImageSize and ImagePadding in all the plots to get the plot area sizes equalized.

 bwc1 = BoxWhiskerChart[data, FrameTicks -> Automatic,
LabelStyle -> Green, FrameLabel -> {{Style["y axis", Bold, 14, Green], None},
{Style["x axis", Bold, 14, Green], None}},
ImageSize -> 300, ImagePadding -> {{85, 5}, {50, 5}}];
bwc2 = BoxWhiskerChart[100 data,
PlotLabel -> Style["line 1\nline 2", Bold],
FrameTicks -> Automatic, LabelStyle -> Directive[Bold, Blue],
FrameLabel -> {{Style["y axis", Bold, 14], None},
{Style["y axis", Bold, 14], None}},
ImageSize -> 300, ImagePadding -> {{85, 5}, {50, 5}}];
bwc3 = BoxWhiskerChart[100000 data,
PlotLabel -> Style["line 1\nline 2\nline 3", Bold, 24],
FrameTicks -> Automatic, LabelStyle -> Directive[Bold, 16, Red],
FrameLabel -> {{Style["y axis", Bold, 14], None},
{Style["y axis", Bold, 14], None}},
ImageSize -> 300, ImagePadding -> {{85, 5}, {50, 5}}];


you get the same plot area size for all three plots:

 Overlay[{bwc1, bwc2, bwc3}, Alignment -> {Right, Bottom}]


But ... "you end up with a lot of extra space between images":

 Grid[{{bwc1, bwc2, bwc3}}, Alignment -> Bottom]


If you wrap each plot in Framed and set the FrameMargins for each to get rid of the extra spaces on the left:

 fbwc1 = Framed[bwc1, FrameStyle -> None, FrameMargins -> {{-50, 0}, {0, 0}}];
fbwc2 = Framed[bwc2, FrameStyle -> None, FrameMargins -> {{-40, 0}, {0, 0}}];
fbwc3 = Framed[bwc3, FrameStyle -> None, FrameMargins -> {{0, 0}, {0, 0}}];


you get equal plot area sizes:

 Overlay[{fbwc1, fbwc2, fbwc3}, Alignment -> {Right, Bottom}]


and no extra spaces on the left:

 Grid[{{fbwc1, fbwc2, fbwc3}}, Alignment -> Bottom]


-
+1 nice use of negative frame margins –  Mike Honeychurch Dec 14 '12 at 22:08
I'm not sure how you could automate this. It looks like a manual method to me ...but if someone is doing a lot of these they can presumably set up a template once and then use repeatedly. –  Mike Honeychurch Dec 14 '12 at 22:09