Consider the following graphic:
g = Graphics[Circle[], Frame -> True, FrameLabel -> {"one", "two"}]
Retrieving the ImagePadding
by traditional means does not work:
AbsoluteOptions[g, ImagePadding]
(* ==> {ImagePadding -> All} *)
My guess for the reason behind this is that it is the Front End that can compute the actual value of the ImagePadding to use, so this can't be obtained without first rasterizing the image in the front end.
Is there some trick to get a numerical value for the ImagePadding
so I can align two figures (make them have the same ImagePadding
) and use an optimal value (not too small cutting off something, not too large wasting space), perhaps by asking the Front End directly?
Note that the ImagePadding
is in absolute coordinates (printer's points, not plot coordinates).
Answer
This almost works but seems to be 1 point off some of the time
im = Image[Show[g, LabelStyle -> White, Background -> White]];
BorderDimensions[im]
For example for
g = Graphics[Circle[], Frame -> True, FrameLabel -> {"one", "two"},
ImagePadding -> {{35, 20}, {40, 50}}]
The output is
{{35, 19}, {40, 50}}
Comments
Post a Comment