<p dir="auto">imshow() ignores or misinterprets the <code class="notranslate">aspect</code> kwarg when <code class="notranslate">interpolation='none'</code>. The bug appears only in svg output, does not seem to be a problem in pdf or png output. The minimal code to reproduce the bug is below:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import matplotlib
matplotlib.use('SVG')
import matplotlib.pyplot as plt

mat = np.ones((40,20))

plt.figure()
plt.subplot(121)
plt.imshow(
    mat,
    aspect=0.5,
    interpolation='nearest')
plt.subplot(122)
plt.imshow(
    mat,
    aspect=0.5,
    interpolation='none')
plt.savefig('/tmp/test.svg')"><pre class="notranslate"><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">import</span> <span class="pl-s1">matplotlib</span>
<span class="pl-s1">matplotlib</span>.<span class="pl-en">use</span>(<span class="pl-s">'SVG'</span>)
<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-s1">mat</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">ones</span>((<span class="pl-c1">40</span>,<span class="pl-c1">20</span>))

<span class="pl-s1">plt</span>.<span class="pl-en">figure</span>()
<span class="pl-s1">plt</span>.<span class="pl-en">subplot</span>(<span class="pl-c1">121</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">imshow</span>(
    <span class="pl-s1">mat</span>,
    <span class="pl-s1">aspect</span><span class="pl-c1">=</span><span class="pl-c1">0.5</span>,
    <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">'nearest'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">subplot</span>(<span class="pl-c1">122</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">imshow</span>(
    <span class="pl-s1">mat</span>,
    <span class="pl-s1">aspect</span><span class="pl-c1">=</span><span class="pl-c1">0.5</span>,
    <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">'none'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s">'/tmp/test.svg'</span>)</pre></div>
<p dir="auto">An image of the output is attached below. The issue also appears when I try to use <code class="notranslate">extent</code> kwarg instead of <code class="notranslate">aspect</code>, i.e. see below (if needed, I can attach an image produced by the second example):</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="plt.figure()
plt.subplot(121)
plt.imshow(
    mat,
    interpolation='nearest',
    extent=[0,20,20,0]

)
plt.subplot(122)
plt.imshow(
    mat,
    interpolation='none',
    extent=[0,20,20,0]
)
plt.savefig('/tmp/test2.svg')"><pre class="notranslate"><span class="pl-s1">plt</span>.<span class="pl-en">figure</span>()
<span class="pl-s1">plt</span>.<span class="pl-en">subplot</span>(<span class="pl-c1">121</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">imshow</span>(
    <span class="pl-s1">mat</span>,
    <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">'nearest'</span>,
    <span class="pl-s1">extent</span><span class="pl-c1">=</span>[<span class="pl-c1">0</span>,<span class="pl-c1">20</span>,<span class="pl-c1">20</span>,<span class="pl-c1">0</span>]

)
<span class="pl-s1">plt</span>.<span class="pl-en">subplot</span>(<span class="pl-c1">122</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">imshow</span>(
    <span class="pl-s1">mat</span>,
    <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">'none'</span>,
    <span class="pl-s1">extent</span><span class="pl-c1">=</span>[<span class="pl-c1">0</span>,<span class="pl-c1">20</span>,<span class="pl-c1">20</span>,<span class="pl-c1">0</span>]
)
<span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s">'/tmp/test2.svg'</span>)</pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/912906/18398220/c15c4496-7699-11e6-8d8b-612c8a3801be.png"><img src="https://cloud.githubusercontent.com/assets/912906/18398220/c15c4496-7699-11e6-8d8b-612c8a3801be.png" alt="svg_aspect_interpolation" style="max-width: 100%;"></a></p>
<p dir="auto">My python environment is:<br>
Ubuntu 16.04, anaconda python distribution, python 3.5.2,  Matplotlib 1.5.1 (from conda)</p>
<h3 dir="auto">Bug report</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec

fig = plt.figure()
gs = gridspec.GridSpec(2, 1)
ax1 = fig.add_subplot(gs[0])
ax2 = fig.add_subplot(gs[1], sharex=ax1)
ax1.set_xticklabels('')
plt.show()"><pre class="notranslate"><code class="notranslate">import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec

fig = plt.figure()
gs = gridspec.GridSpec(2, 1)
ax1 = fig.add_subplot(gs[0])
ax2 = fig.add_subplot(gs[1], sharex=ax1)
ax1.set_xticklabels('')
plt.show()
</code></pre></div>
<p dir="auto">makes the ticklabels on <code class="notranslate">ax2</code> disappear as well.</p>
<p dir="auto">Similarly:</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 matplotlib.ticker as mticker
import matplotlib.gridspec as gridspec

fig = plt.figure()
gs = gridspec.GridSpec(2, 1)
ax1 = fig.add_subplot(gs[0])
ax2 = fig.add_subplot(gs[1], sharex=ax1)
ax1.xaxis.set_major_formatter(mticker.NullFormatter())
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">matplotlib</span>.<span class="pl-s1">ticker</span> <span class="pl-k">as</span> <span class="pl-s1">mticker</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">gridspec</span> <span class="pl-k">as</span> <span class="pl-s1">gridspec</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-s1">gs</span> <span class="pl-c1">=</span> <span class="pl-s1">gridspec</span>.<span class="pl-v">GridSpec</span>(<span class="pl-c1">2</span>, <span class="pl-c1">1</span>)
<span class="pl-s1">ax1</span> <span class="pl-c1">=</span> <span class="pl-s1">fig</span>.<span class="pl-en">add_subplot</span>(<span class="pl-s1">gs</span>[<span class="pl-c1">0</span>])
<span class="pl-s1">ax2</span> <span class="pl-c1">=</span> <span class="pl-s1">fig</span>.<span class="pl-en">add_subplot</span>(<span class="pl-s1">gs</span>[<span class="pl-c1">1</span>], <span class="pl-s1">sharex</span><span class="pl-c1">=</span><span class="pl-s1">ax1</span>)
<span class="pl-s1">ax1</span>.<span class="pl-s1">xaxis</span>.<span class="pl-en">set_major_formatter</span>(<span class="pl-s1">mticker</span>.<span class="pl-v">NullFormatter</span>())
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto">appears to share the formatter.</p>
<p dir="auto">This means that we can't manually duplicate the behaviour of <code class="notranslate">fig, ax = plt.subplots(sharex=True)</code>.  The reason I need to do it manually is something more complicated:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
fig = plt.figure(constrained_layout=True)
gs = gridspec.GridSpec(2, 1)
gs_top = gridspec.GridSpecFromSubplotSpec(1, 2, gs[0])
gs_bot = gridspec.GridSpecFromSubplotSpec(1, 2, gs[1])
ax_top=[]
ax_bot=[]
for i in range(2):
    if i &gt; 0:
        ax_top += [fig.add_subplot(gs_top[i], sharex=ax_top[0], sharey=ax_top[0])]
    else:
        ax_top += [fig.add_subplot(gs_top[i])]

    ax_bot += [fig.add_subplot(gs_bot[i], sharex=ax_top[0], sharey=ax_top[0])]
    pctop = ax_top[i].pcolormesh(np.random.randn(20, 20))
    ax_top[i].set_xticklabels('')
    pcbot = ax_bot[i].pcolormesh(np.random.randn(20, 20), cmap='RdBu_r')
    #if i == 1:
    #    ax_top[i].set_yticklabels('')
    #    ax_bot[i].set_yticklabels('')
    
fig.colorbar(pctop, ax=ax_top)
fig.colorbar(pcbot, ax=ax_bot)"><pre class="notranslate"><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-s1">constrained_layout</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
<span class="pl-s1">gs</span> <span class="pl-c1">=</span> <span class="pl-s1">gridspec</span>.<span class="pl-v">GridSpec</span>(<span class="pl-c1">2</span>, <span class="pl-c1">1</span>)
<span class="pl-s1">gs_top</span> <span class="pl-c1">=</span> <span class="pl-s1">gridspec</span>.<span class="pl-v">GridSpecFromSubplotSpec</span>(<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-s1">gs</span>[<span class="pl-c1">0</span>])
<span class="pl-s1">gs_bot</span> <span class="pl-c1">=</span> <span class="pl-s1">gridspec</span>.<span class="pl-v">GridSpecFromSubplotSpec</span>(<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-s1">gs</span>[<span class="pl-c1">1</span>])
<span class="pl-s1">ax_top</span><span class="pl-c1">=</span>[]
<span class="pl-s1">ax_bot</span><span class="pl-c1">=</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">2</span>):
    <span class="pl-k">if</span> <span class="pl-s1">i</span> <span class="pl-c1">&gt;</span> <span class="pl-c1">0</span>:
        <span class="pl-s1">ax_top</span> <span class="pl-c1">+=</span> [<span class="pl-s1">fig</span>.<span class="pl-en">add_subplot</span>(<span class="pl-s1">gs_top</span>[<span class="pl-s1">i</span>], <span class="pl-s1">sharex</span><span class="pl-c1">=</span><span class="pl-s1">ax_top</span>[<span class="pl-c1">0</span>], <span class="pl-s1">sharey</span><span class="pl-c1">=</span><span class="pl-s1">ax_top</span>[<span class="pl-c1">0</span>])]
    <span class="pl-k">else</span>:
        <span class="pl-s1">ax_top</span> <span class="pl-c1">+=</span> [<span class="pl-s1">fig</span>.<span class="pl-en">add_subplot</span>(<span class="pl-s1">gs_top</span>[<span class="pl-s1">i</span>])]

    <span class="pl-s1">ax_bot</span> <span class="pl-c1">+=</span> [<span class="pl-s1">fig</span>.<span class="pl-en">add_subplot</span>(<span class="pl-s1">gs_bot</span>[<span class="pl-s1">i</span>], <span class="pl-s1">sharex</span><span class="pl-c1">=</span><span class="pl-s1">ax_top</span>[<span class="pl-c1">0</span>], <span class="pl-s1">sharey</span><span class="pl-c1">=</span><span class="pl-s1">ax_top</span>[<span class="pl-c1">0</span>])]
    <span class="pl-s1">pctop</span> <span class="pl-c1">=</span> <span class="pl-s1">ax_top</span>[<span class="pl-s1">i</span>].<span class="pl-en">pcolormesh</span>(<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randn</span>(<span class="pl-c1">20</span>, <span class="pl-c1">20</span>))
    <span class="pl-s1">ax_top</span>[<span class="pl-s1">i</span>].<span class="pl-en">set_xticklabels</span>(<span class="pl-s">''</span>)
    <span class="pl-s1">pcbot</span> <span class="pl-c1">=</span> <span class="pl-s1">ax_bot</span>[<span class="pl-s1">i</span>].<span class="pl-en">pcolormesh</span>(<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randn</span>(<span class="pl-c1">20</span>, <span class="pl-c1">20</span>), <span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s">'RdBu_r'</span>)
    <span class="pl-c">#if i == 1:</span>
    <span class="pl-c">#    ax_top[i].set_yticklabels('')</span>
    <span class="pl-c">#    ax_bot[i].set_yticklabels('')</span>
    
<span class="pl-s1">fig</span>.<span class="pl-en">colorbar</span>(<span class="pl-s1">pctop</span>, <span class="pl-s1">ax</span><span class="pl-c1">=</span><span class="pl-s1">ax_top</span>)
<span class="pl-s1">fig</span>.<span class="pl-en">colorbar</span>(<span class="pl-s1">pcbot</span>, <span class="pl-s1">ax</span><span class="pl-c1">=</span><span class="pl-s1">ax_bot</span>)</pre></div>