Given Graphics
object, how do I determine the range of coordinates needed to include all of graphics? Basically I need something like what Show
does by default, but I want to specify PlotRange
,PlotRangePadding
and ImagePadding
explicitly.
Example, two Show
s below should render the same
g = Graphics[{Thickness[1], CapForm["Round"], Line[{{0, 0}, {1, 1}}]}];
Show[g]
Show[g, PlotRange -> getPlotRange[g], PlotRangePadding->getPlotRangePadding[g], ImagePadding->getImagePadding[g]]
Motivation: fixing diagrams in this question
Update:
AbsoluteOptions
gives me PlotRange
but not the other two options. Explicitly specifying ImagePadding->Automatic
changes appearance though it's supposedly Automatic
by default.
Two images below show differently and I don't understand why
g = Graphics[{Thickness[1], CapForm["Round"], Line[{{0, 0}, {1, 1}}]}];
Show[g]
Show[g, Sequence @@ AbsoluteOptions[Show[g]]]
Update 2: A similar problem was brought up a year ago, with no solutions proposed, and not fixed as of Mathematica 8.0. To summarize
- There's no way to reproduce
Show[g]
above with explicit setting ofPlotRange
- There's no way to get absolute
ImagePadding
used byShow[g]
Show[g,PlotRange->Automatic]
looks different fromShow[g]
AbsoluteOptions
can give the wrong result forPlotRange