<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">The <code class="notranslate">ImageGrid</code> class seems to not behave correctly since the upgrade to matplotlib <code class="notranslate">3.0.0</code> when the <code class="notranslate">inline</code> backend is used in a Jupyter notebook: the resulting subplots fail to arrange in a grid and are placed on top of eachother. The correct behaviour is reproduced if using the <code class="notranslate">notebook</code> or <code class="notranslate">ipympl</code> backends. Thanks!</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
import numpy as np

im = np.arange(100)
im.shape = 10, 10

fig = plt.figure(1, (4., 4.))
grid = ImageGrid(fig, 111,  
                 nrows_ncols=(2, 2),  
                 axes_pad=0.1,  
                 )

for i in range(4):
    grid[i].imshow(im)  
    grid[i].set_title('test {0}{0}'.format(i)) 

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">from</span> <span class="pl-s1">mpl_toolkits</span>.<span class="pl-s1">axes_grid1</span> <span class="pl-k">import</span> <span class="pl-v">ImageGrid</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">im</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">100</span>)
<span class="pl-s1">im</span>.<span class="pl-s1">shape</span> <span class="pl-c1">=</span> <span class="pl-c1">10</span>, <span class="pl-c1">10</span>

<span class="pl-s1">fig</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">figure</span>(<span class="pl-c1">1</span>, (<span class="pl-c1">4.</span>, <span class="pl-c1">4.</span>))
<span class="pl-s1">grid</span> <span class="pl-c1">=</span> <span class="pl-v">ImageGrid</span>(<span class="pl-s1">fig</span>, <span class="pl-c1">111</span>,  
                 <span class="pl-s1">nrows_ncols</span><span class="pl-c1">=</span>(<span class="pl-c1">2</span>, <span class="pl-c1">2</span>),  
                 <span class="pl-s1">axes_pad</span><span class="pl-c1">=</span><span class="pl-c1">0.1</span>,  
                 )

<span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-c1">4</span>):
    <span class="pl-s1">grid</span>[<span class="pl-s1">i</span>].<span class="pl-en">imshow</span>(<span class="pl-s1">im</span>)  
    <span class="pl-s1">grid</span>[<span class="pl-s1">i</span>].<span class="pl-en">set_title</span>(<span class="pl-s">'test {0}{0}'</span>.<span class="pl-en">format</span>(<span class="pl-s1">i</span>)) 

<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/15064659/46354323-9d1dc700-c65e-11e8-9cf1-c8fdc40e9acf.png"><img src="https://user-images.githubusercontent.com/15064659/46354323-9d1dc700-c65e-11e8-9cf1-c8fdc40e9acf.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/15064659/46354286-88d9ca00-c65e-11e8-991f-7dfe32c4a529.png"><img src="https://user-images.githubusercontent.com/15064659/46354286-88d9ca00-c65e-11e8-991f-7dfe32c4a529.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Operating system: Debian 9</li>
<li>Matplotlib version: 3.0.0</li>
<li>Matplotlib backend: <code class="notranslate">inline</code></li>
<li>Python version: 3.5.3</li>
<li>Jupyter version (if applicable): 4.4.0</li>
<li>Other libraries:</li>
</ul>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>

<p dir="auto">When setting bbox_inches='tight' in savefig function, the colorbar is plotted in the wrong way.</p>
<p dir="auto"><strong>Code for reproduction</strong></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
from mpl_toolkits.basemap import Basemap

outfile = r'E:\wrong.tif'

# read in data on lat/lon grid.
hgt = np.loadtxt(r'E:\tmp\basemap\500hgtdata.gz')
lons = np.loadtxt(r'E:\tmp\basemap\500hgtlons.gz')
lats = np.loadtxt(r'E:\tmp\basemap\500hgtlats.gz')
lons, lats = np.meshgrid(lons, lats)

mnh = Basemap(lon_0=-105, boundinglat=20.,
              resolution='c', area_thresh=10000., projection='nplaea')
xnh, ynh = mnh(lons, lats)
CS = mnh.contour(xnh, ynh, hgt, 15, linewidths=0.5, colors='k')
CS = mnh.contourf(xnh, ynh, hgt, 15, cmap=plt.cm.Spectral)

mnh.drawcoastlines(linewidth=0.5)
delat = 30.
circles = np.arange(0., 90., delat).tolist() + \
          np.arange(-delat, -90, -delat).tolist()
mnh.drawparallels(circles, labels=[1, 0, 0, 0])
delon = 45.
meridians = np.arange(0, 360, delon)
mnh.drawmeridians(meridians, labels=[1, 0, 0, 1])
plt.title('NH 500 hPa Height (cm.Spectral)')

# colorbar on bottom.
mnh.colorbar(pad='5%')
plt.savefig(outfile, dpi=300, bbox_inches='tight')  # wrong
# plt.savefig(outfile, dpi=300) # right
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-k">from</span> <span class="pl-s1">mpl_toolkits</span>.<span class="pl-s1">basemap</span> <span class="pl-k">import</span> <span class="pl-v">Basemap</span>

<span class="pl-s1">outfile</span> <span class="pl-c1">=</span> <span class="pl-s">r'E:\wrong.tif'</span>

<span class="pl-c"># read in data on lat/lon grid.</span>
<span class="pl-s1">hgt</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">loadtxt</span>(<span class="pl-s">r'E:\tmp\basemap\500hgtdata.gz'</span>)
<span class="pl-s1">lons</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">loadtxt</span>(<span class="pl-s">r'E:\tmp\basemap\500hgtlons.gz'</span>)
<span class="pl-s1">lats</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">loadtxt</span>(<span class="pl-s">r'E:\tmp\basemap\500hgtlats.gz'</span>)
<span class="pl-s1">lons</span>, <span class="pl-s1">lats</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">meshgrid</span>(<span class="pl-s1">lons</span>, <span class="pl-s1">lats</span>)

<span class="pl-s1">mnh</span> <span class="pl-c1">=</span> <span class="pl-v">Basemap</span>(<span class="pl-s1">lon_0</span><span class="pl-c1">=</span><span class="pl-c1">-</span><span class="pl-c1">105</span>, <span class="pl-s1">boundinglat</span><span class="pl-c1">=</span><span class="pl-c1">20.</span>,
              <span class="pl-s1">resolution</span><span class="pl-c1">=</span><span class="pl-s">'c'</span>, <span class="pl-s1">area_thresh</span><span class="pl-c1">=</span><span class="pl-c1">10000.</span>, <span class="pl-s1">projection</span><span class="pl-c1">=</span><span class="pl-s">'nplaea'</span>)
<span class="pl-s1">xnh</span>, <span class="pl-s1">ynh</span> <span class="pl-c1">=</span> <span class="pl-en">mnh</span>(<span class="pl-s1">lons</span>, <span class="pl-s1">lats</span>)
<span class="pl-v">CS</span> <span class="pl-c1">=</span> <span class="pl-s1">mnh</span>.<span class="pl-en">contour</span>(<span class="pl-s1">xnh</span>, <span class="pl-s1">ynh</span>, <span class="pl-s1">hgt</span>, <span class="pl-c1">15</span>, <span class="pl-s1">linewidths</span><span class="pl-c1">=</span><span class="pl-c1">0.5</span>, <span class="pl-s1">colors</span><span class="pl-c1">=</span><span class="pl-s">'k'</span>)
<span class="pl-v">CS</span> <span class="pl-c1">=</span> <span class="pl-s1">mnh</span>.<span class="pl-en">contourf</span>(<span class="pl-s1">xnh</span>, <span class="pl-s1">ynh</span>, <span class="pl-s1">hgt</span>, <span class="pl-c1">15</span>, <span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s1">plt</span>.<span class="pl-s1">cm</span>.<span class="pl-v">Spectral</span>)

<span class="pl-s1">mnh</span>.<span class="pl-en">drawcoastlines</span>(<span class="pl-s1">linewidth</span><span class="pl-c1">=</span><span class="pl-c1">0.5</span>)
<span class="pl-s1">delat</span> <span class="pl-c1">=</span> <span class="pl-c1">30.</span>
<span class="pl-s1">circles</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">0.</span>, <span class="pl-c1">90.</span>, <span class="pl-s1">delat</span>).<span class="pl-en">tolist</span>() <span class="pl-c1">+</span> \
          <span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">-</span><span class="pl-s1">delat</span>, <span class="pl-c1">-</span><span class="pl-c1">90</span>, <span class="pl-c1">-</span><span class="pl-s1">delat</span>).<span class="pl-en">tolist</span>()
<span class="pl-s1">mnh</span>.<span class="pl-en">drawparallels</span>(<span class="pl-s1">circles</span>, <span class="pl-s1">labels</span><span class="pl-c1">=</span>[<span class="pl-c1">1</span>, <span class="pl-c1">0</span>, <span class="pl-c1">0</span>, <span class="pl-c1">0</span>])
<span class="pl-s1">delon</span> <span class="pl-c1">=</span> <span class="pl-c1">45.</span>
<span class="pl-s1">meridians</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">0</span>, <span class="pl-c1">360</span>, <span class="pl-s1">delon</span>)
<span class="pl-s1">mnh</span>.<span class="pl-en">drawmeridians</span>(<span class="pl-s1">meridians</span>, <span class="pl-s1">labels</span><span class="pl-c1">=</span>[<span class="pl-c1">1</span>, <span class="pl-c1">0</span>, <span class="pl-c1">0</span>, <span class="pl-c1">1</span>])
<span class="pl-s1">plt</span>.<span class="pl-en">title</span>(<span class="pl-s">'NH 500 hPa Height (cm.Spectral)'</span>)

<span class="pl-c"># colorbar on bottom.</span>
<span class="pl-s1">mnh</span>.<span class="pl-en">colorbar</span>(<span class="pl-s1">pad</span><span class="pl-c1">=</span><span class="pl-s">'5%'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s1">outfile</span>, <span class="pl-s1">dpi</span><span class="pl-c1">=</span><span class="pl-c1">300</span>, <span class="pl-s1">bbox_inches</span><span class="pl-c1">=</span><span class="pl-s">'tight'</span>)  <span class="pl-c"># wrong</span>
<span class="pl-c"># plt.savefig(outfile, dpi=300) # right</span>
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>

<p dir="auto">The wrong one:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/6754276/46267605-74b3a100-c568-11e8-8f52-72a38318b7ee.png"><img src="https://user-images.githubusercontent.com/6754276/46267605-74b3a100-c568-11e8-8f52-72a38318b7ee.png" alt="default" style="max-width: 100%;"></a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# If applicable, paste the console output here
# None
#"><pre class="notranslate"><code class="notranslate"># If applicable, paste the console output here
# None
#
</code></pre></div>
<p dir="auto"><strong>Expected outcome</strong></p>


<p dir="auto">The correct figure:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/6754276/46267594-68c7df00-c568-11e8-9d65-8a379ba1540e.png"><img src="https://user-images.githubusercontent.com/6754276/46267594-68c7df00-c568-11e8-9d65-8a379ba1540e.png" alt="default" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system: Windows 10 x64</li>
<li>Matplotlib version:  3.0.0</li>
<li>Matplotlib backend (<code class="notranslate">print(matplotlib.get_backend())</code>): module://backend_interagg</li>
<li>Python version: 3.6.6</li>
<li>Jupyter version (if applicable): None</li>
<li>basemap version: 1.2.0</li>
<li>PyCharm version: 2018.2.4</li>
</ul>


<p dir="auto">I install matplotlib and basemap from <a href="https://www.lfd.uci.edu/~gohlke/pythonlibs" rel="nofollow">https://www.lfd.uci.edu/~gohlke/pythonlibs</a>.</p>