Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I, too, sometimes find it confusing how to get Mathematica to display <code>Graphics</code> in a consistent way, particularly when insetting graphics.</p> <p>For the specified graphic <code>g</code>, it doesn't matter what you provide for the <code>PlotRange</code>, because <code>Thickness[1]</code> always draws a line whose thickness is equal to the horizontal plot range. In your example, <code>Show[g, ___]</code> gives the correct result:</p> <p><img src="https://i.stack.imgur.com/NKgmH.png" alt="automatic image padding">. </p> <p><code>Show[g]</code>, or simply <code>g</code>, is anomalous. </p> <p>Why?</p> <p>I don't know where/if this is documented, but here are a few things that might be relevant to the question. </p> <ol> <li><p>Obviously <code>DisplayForm[Graphics[___]]</code> is a raster. </p></li> <li><p>We can get a raster for g using Rasterize[g]. What is the RasterSize? From trial and error, I found that RasterSize is 10 * screen resolution (reported as 72 pixels per inch on my system). How do I know this? If I rasterize g with resolutions less than 718, I get an image with dimensions {360,361}, whereas the default image size for g is 360 pixels on my system, so I figure to Show[] a graphic, Mathematica <code>Rasterize</code>'s it at 10x the screen resolution. Anybody know if this is true? You can get your screen resolution (at least as Mathematica sees it) from the Options Inspector. <strong>Edit</strong> That the following expression evaluates as <code>True</code> seems to show that the displayed graphic is rasterized at the ImageSize: <code>ImportString[ExportString[Show[g,ImageSize-&gt;100],"PNG"]] === ImportString[ExportString[Rasterize[g,RasterSize-&gt;100,ImageSize-&gt;100],"PNG"]</code></p></li> <li><p>To reproduce <code>Show[g]</code> when using <code>PlotRange</code> I need to use <code>Show[g,PlotRange-&gt;{{0,1},{0,1}},ImagePadding-&gt;90.3]</code></p></li> </ol> <p><img src="https://i.stack.imgur.com/K4vG2.png" alt="specific image padding"></p> <p>to get it to crop to the perimeter of the line. So it seems that Mathematica is telling the truth that the <code>PlotRange</code> is <code>{{0,1},{0,1}}</code> when using <code>AbsoluteOptions[]</code>. It is not reporting the actual value of <code>ImagePadding</code>. Perhaps because <code>ImagePadding-&gt;Automatic</code> is based on a rule that uses the current <code>ImageSize</code>, <code>PlotRangeClipping</code>,... settings? The <code>ImagePadding</code> of 90.3 only works for <code>ImageSize-&gt;360</code>; setting <code>ImageSize-&gt;200</code> makes the <code>ImagePadding</code> value wrong. For your graphic, <code>ImagePadding-&gt;90.3*OptionValue[ImageSize]/360</code> reproduces <code>Show[g,ImageSize-&gt;_]</code> on my system.</p> <p>That's all I've found out so far.</p>
 

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