<p dir="auto">Originally reported by Anik Halder on the mailing list <a href="http://matplotlib.1069221.n5.nabble.com/IPython-FITS-file-plotting-problem-tp47271.html" rel="nofollow">http://matplotlib.1069221.n5.nabble.com/IPython-FITS-file-plotting-problem-tp47271.html</a></p>
<p dir="auto">Consider this simple example:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
import numpy as np

x = np.arange(10)
X, Y = np.meshgrid(x,x)
Z = ((X-5)**2 + (Y-5)**2)**0.5

plt.imshow(Z, origin = &quot;lower&quot;)
plt.colorbar()
plt.show()

plt.figure()
plt.imshow(Z.astype('&gt;f8'), origin = &quot;lower&quot;)
plt.colorbar()
plt.show()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">10</span>)
<span class="pl-v">X</span>, <span class="pl-v">Y</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">meshgrid</span>(<span class="pl-s1">x</span>,<span class="pl-s1">x</span>)
<span class="pl-v">Z</span> <span class="pl-c1">=</span> ((<span class="pl-v">X</span><span class="pl-c1">-</span><span class="pl-c1">5</span>)<span class="pl-c1">**</span><span class="pl-c1">2</span> <span class="pl-c1">+</span> (<span class="pl-v">Y</span><span class="pl-c1">-</span><span class="pl-c1">5</span>)<span class="pl-c1">**</span><span class="pl-c1">2</span>)<span class="pl-c1">**</span><span class="pl-c1">0.5</span>

<span class="pl-s1">plt</span>.<span class="pl-en">imshow</span>(<span class="pl-v">Z</span>, <span class="pl-s1">origin</span> <span class="pl-c1">=</span> <span class="pl-s">"lower"</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">colorbar</span>()
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()

<span class="pl-s1">plt</span>.<span class="pl-en">figure</span>()
<span class="pl-s1">plt</span>.<span class="pl-en">imshow</span>(<span class="pl-v">Z</span>.<span class="pl-en">astype</span>(<span class="pl-s">'&gt;f8'</span>), <span class="pl-s1">origin</span> <span class="pl-c1">=</span> <span class="pl-s">"lower"</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">colorbar</span>()
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto">Which produces:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/548266/16527177/3c6c6a86-3fad-11e6-843e-6a17a6afeab3.png"><img src="https://cloud.githubusercontent.com/assets/548266/16527177/3c6c6a86-3fad-11e6-843e-6a17a6afeab3.png" alt="right" style="max-width: 100%;"></a><br>
And:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/548266/16527178/3e7af0cc-3fad-11e6-9b95-fdd75809b79e.png"><img src="https://cloud.githubusercontent.com/assets/548266/16527178/3e7af0cc-3fad-11e6-9b95-fdd75809b79e.png" alt="wrong" style="max-width: 100%;"></a></p>
<p dir="auto">This works correctly in 1.5.1 so it looks like it's a regression in 2.x</p>
<p dir="auto">The following minimal example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import matplotlib
matplotlib.use('Agg')
from astropy.wcs import WCS
from wcsaxes import datasets
import matplotlib.pyplot as plt
hdu = datasets.fetch_msx_hdu()
plt.imshow(hdu.data, vmin=-2e-4, vmax=2e-4)
plt.savefig('image.png')"><pre class="notranslate"><code class="notranslate">import matplotlib
matplotlib.use('Agg')
from astropy.wcs import WCS
from wcsaxes import datasets
import matplotlib.pyplot as plt
hdu = datasets.fetch_msx_hdu()
plt.imshow(hdu.data, vmin=-2e-4, vmax=2e-4)
plt.savefig('image.png')
</code></pre></div>
<p dir="auto">produces the following output:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/314716/15148599/dedc6636-16bd-11e6-83f8-a06d4c5f5757.png"><img src="https://cloud.githubusercontent.com/assets/314716/15148599/dedc6636-16bd-11e6-83f8-a06d4c5f5757.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">This appears to be related to the fact the values in the image data are &lt; 1. If I multiply all the values by 1e6, I get something sensible:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="plt.imshow(hdu.data * 1e6, vmin=-2e-4, vmax=2e-4)
plt.savefig('image.png')"><pre class="notranslate"><code class="notranslate">plt.imshow(hdu.data * 1e6, vmin=-2e-4, vmax=2e-4)
plt.savefig('image.png')
</code></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/314716/15148648/26fd7162-16be-11e6-84b9-347e388d99f2.png"><img src="https://cloud.githubusercontent.com/assets/314716/15148648/26fd7162-16be-11e6-84b9-347e388d99f2.png" alt="image" style="max-width: 100%;"></a></p>