<div>On Fri, Oct 20, 2017 at 3:00 PM Jody Klymak <<a href="mailto:jklymak@uvic.ca">jklymak@uvic.ca</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div>Hi David,</div><div><br></div><div>What are you trying to achieve as the output?  An image with no white space?  </div></div></blockquote><div dir="auto"><br></div><div dir="auto">Yes, and no edge, but one that replaces that white space with my figure.  in other words, if what is going on is that my figure w/ the white space is what is 3600x2400, how do I get the full 3600x2400 to be my figure? (I don’t care if it puts white space around that because I figured out an “alternative” way to get rid of that).  But mostly, I’d just like to understand what’s going on, because what’s happening now makes absolutely no sense to me whatsoever.</div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div></div><div><br></div>`bbox_inches=tight` changes the size of the figure to get rid of white space around it.  Prob not what you really want.</div></blockquote><div dir="auto"><br></div><div dir="auto">OK, so that may be the problem: what’s the “proper” way to “get rid of” the white space, module what I said above.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div></div></div></blockquote><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><br></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div>Drilling down into `canvas` shouldn’t really be necessary. </div></div></blockquote><div dir="auto"><br></div><div dir="auto">I’m all ears.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div></div><div><br></div><div>What is `PLB`?  etc?</div></div></blockquote><div dir="auto"><br></div><div dir="auto">import pylab as PLB</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div></div><div><br></div><div>This will get you pretty close if you just want an image w/ no white space.  But I’m not 100% sure that every pixel has been preserved…</div><div><br></div><div><br></div><div><div>```</div><div>import matplotlib.pyplot as plt</div><div>import numpy as np</div><div><br></div><div>im = np.floor(np.random.rand(3601,2401)*100)</div><div><br></div><div>fig, ax = plt.subplots(figsize = (2401/300, 3601/300), dpi=300)</div><div><br></div><div># turn off axis and labels</div><div>ax.set_axis_off()</div><div># fill the figure</div><div>ax.set_position([0., 0., 1., 1.])</div><div>ax.imshow(im)</div><div>fig.savefig('Test.png', dpi=300)</div></div></div></blockquote><div dir="auto"><br></div><div dir="auto">Ok, I’ll try that, thanks.</div><div dir="auto"><br></div><div dir="auto">DLG</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div></div></div><div>```</div><div><br></div><div><br></div><div><br><div><br><blockquote type="cite"></blockquote></div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div><blockquote type="cite"><div>On 20 Oct 2017, at  14:38 PM, David Goldsmith <<a href="mailto:eulergaussriemann@gmail.com" target="_blank">eulergaussriemann@gmail.com</a>> wrote:</div><br class="m_-4382403071323783468Apple-interchange-newline"></blockquote></div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div><blockquote type="cite"><div><div>Hi!  I spent a good part of yesterday trying to figure this out on my own, without success, so I'm posting.  I have a 3601x2401 pixel, 300 DPI figure I export to a png using print_figure; here's sample code:<div><br></div><div><pre style="font-family:Menlo;font-size:9pt">PLB.imshow(rslt) # rslt is a 3601x2401 int-valued array<br>curfig = PLB.Figure<br>fig = PLB.gcf() <br># next three lines are in my code; don't seem relevant, but I include them in case they are</pre><pre style="font-family:Menlo;font-size:9pt">ax = fig.gca()<br>ax.xaxis.set_ticks([]) <br>ax.yaxis.set_ticks([])<br><br></pre><pre style="font-family:Menlo;font-size:9pt">fig.canvas.print_figure(fn + <span style="color:rgb(0,128,128);font-weight:bold">'.png'</span>,<br>                        <span style="font-size:9pt;color:rgb(102,0,153)">dpi</span><span style="font-size:9pt">=300,</span></pre><pre style="font-family:Menlo;font-size:9pt">                        bbox_inches<span style="font-size:9pt">=</span><span style="font-size:9pt;color:rgb(0,128,128);font-weight:bold">'tight'</span><span style="font-size:9pt">, </span></pre><pre style="font-family:Menlo;font-size:9pt"><span style="font-size:9pt;color:rgb(102,0,153)">                        pad_inches</span><span style="font-size:9pt">=-</span><span style="font-size:9pt;color:rgb(0,0,255)">1.0 </span><span style="font-size:9pt">/ </span><span style="font-size:9pt;color:rgb(0,0,255)">72)</span></pre><pre style="font-family:Menlo;font-size:9pt"><font>The resulting png is neither the right number of pixels by pixels, nor the right number of inches by incheses; what's more the resulting png differs depending on whether I use imshow or matshow (which I also tried).</font></pre><pre style="font-family:Menlo;font-size:9pt"><font>What's going on, and how do I "fix" it?  (If I really am getting the full resolution figure, despite what the png is telling me are the pixel counts, why are the physical dimensions off, and why is the png telling me that the pixel counts are different?  If it has something to do with compression, is there some  undocumented way to say "no compression" and will that have the desired effect?)</font></pre><pre style="font-family:Menlo;font-size:9pt"><font>Thanks!</font></pre><pre style="font-family:Menlo;font-size:9pt">DLG <br></pre><pre style="font-family:Menlo;font-size:9pt"><span style="font-size:9pt;color:rgb(0,0,255)"><br></span></pre></div></div></div></blockquote></div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div><blockquote type="cite"><div>
_______________________________________________<br>Matplotlib-users mailing list<br><a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br><a href="https://mail.python.org/mailman/listinfo/matplotlib-users" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br></div></blockquote></div><br><div>
<span class="m_-4382403071323783468Apple-style-span" style="border-collapse:separate;border-spacing:0px;font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal"><div style="word-wrap:break-word"><span class="m_-4382403071323783468Apple-style-span" style="border-collapse:separate;border-spacing:0px;color:rgb(0,0,0);font-family:'Lucida Sans Typewriter';font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div>--</div><div>Jody Klymak    </div><div><a href="http://web.uvic.ca/~jklymak/" target="_blank">http://web.uvic.ca/~jklymak/</a></div><div><br class="m_-4382403071323783468khtml-block-placeholder"></div><div><br class="m_-4382403071323783468khtml-block-placeholder"></div><br class="m_-4382403071323783468Apple-interchange-newline"></span></div></span><br class="m_-4382403071323783468Apple-interchange-newline">
</div>
<br></div></div></blockquote></div></div>