Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to determine PlotRange to include all of graphics?
    text
    copied!<p>Given <code>Graphics</code> object, how do I determine the range of coordinates needed to include all of graphics? Basically I need something like what <code>Show</code> does by default, but I want to specify <code>PlotRange</code>,<code>PlotRangePadding</code> and <code>ImagePadding</code> explicitly.</p> <p>Example, two <code>Show</code>s below should render the same</p> <pre><code>g = Graphics[{Thickness[1], CapForm["Round"], Line[{{0, 0}, {1, 1}}]}]; Show[g] Show[g, PlotRange -&gt; getPlotRange[g], PlotRangePadding-&gt;getPlotRangePadding[g], ImagePadding-&gt;getImagePadding[g]] </code></pre> <p>Motivation: fixing diagrams in <a href="https://stackoverflow.com/questions/4230823/consistent-size-for-graphplots">this</a> question</p> <p><b>Update</b>: <code>AbsoluteOptions</code> gives me <code>PlotRange</code> but not the other two options. Explicitly specifying <code>ImagePadding-&gt;Automatic</code> changes appearance though it's supposedly <code>Automatic</code> by default.</p> <p>Two images below show differently and I don't understand why</p> <pre><code>g = Graphics[{Thickness[1], CapForm["Round"], Line[{{0, 0}, {1, 1}}]}]; Show[g] Show[g, Sequence @@ AbsoluteOptions[Show[g]]] </code></pre> <p><b>Update 2</b>: A similar problem was <a href="http://forums.wolfram.com/mathgroup/archive/2009/Nov/msg00144.html" rel="nofollow noreferrer">brought up</a> a year ago, with no solutions proposed, and not fixed as of Mathematica 8.0. To summarize</p> <ol> <li>There's no way to reproduce <code>Show[g]</code> above with explicit setting of <code>PlotRange</code></li> <li>There's no way to get absolute <code>ImagePadding</code> used by <code>Show[g]</code></li> <li><code>Show[g,PlotRange-&gt;Automatic]</code> looks different from <code>Show[g]</code></li> <li><code>AbsoluteOptions</code> can give the <a href="http://forums.wolfram.com/mathgroup/archive/2009/Nov/msg00144.html" rel="nofollow noreferrer">wrong result</a> for <code>PlotRange</code></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload