<p dir="auto"><a href="https://stackoverflow.com/questions/48453346/arguments-for-imshow-in-matplotlib-are-ambiguous" rel="nofollow">This Stackoverflow question</a> brings the confusing matrix dimensions used in the <a href="https://matplotlib.org/api/_as_gen/matplotlib.pyplot.imshow.html?highlight=matplotlib%20pyplot%20imshow#matplotlib.pyplot.imshow" rel="nofollow"><code class="notranslate">imshow</code> documentation</a> to our attention.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/23121882/35418515-e0bc43f6-0232-11e8-8797-f2ed98149f80.png"><img src="https://user-images.githubusercontent.com/23121882/35418515-e0bc43f6-0232-11e8-8797-f2ed98149f80.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">According to the docstring one may use arrays of shapes <code class="notranslate">(n, m)</code> etc. which are then named <code class="notranslate">MxN</code>.</p>
<p dir="auto">However, according to <a href="https://en.wikipedia.org/wiki/Matrix_(mathematics)" rel="nofollow">wikipedia</a></p>
<blockquote>
<p dir="auto">A matrix with m rows and n columns is called an m × n matrix or m-by-n matrix.</p>
</blockquote>
<p dir="auto">This is also the convention used by numpy, e.g. the <a href="https://docs.scipy.org/doc/numpy-1.13.0/reference/arrays.ndarray.html" rel="nofollow">arrays.ndarray.html</a> speaks about</p>
<blockquote>
<p dir="auto">A 2-dimensional array of size 2 x 3, composed of 4-byte integer elements:<br>
<code class="notranslate">x = np.array([[1, 2, 3], [4, 5, 6]], np.int32)</code></p>
</blockquote>
<p dir="auto">The documentation should therefore either speak of</p>
<ul dir="auto">
<li>shape <code class="notranslate">(n, m)</code>, or <code class="notranslate">n x m</code> array (<code class="notranslate">nxm</code> looks strange)</li>
<li>shape <code class="notranslate">(N, M)</code> or <code class="notranslate">NxM</code> array</li>
<li>shape <code class="notranslate">(m, n)</code> or <code class="notranslate">m x n</code> array</li>
<li>shape <code class="notranslate">(M, N)</code> or <code class="notranslate">M x N</code> array</li>
</ul>
<p dir="auto">Now, which is better? All capitalized or not, <code class="notranslate">n</code> or <code class="notranslate">m</code> being rows?</p>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">Using savefig to pdf and png, outputs are different.</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 numpy as np
import matplotlib.pyplot as plt
from matplotlib.offsetbox import AnchoredText

fig, ax = plt.subplots(1, 1, figsize=(3.2, 3.2))

ax.imshow(np.random.rand(100 ,100), cmap='Blues', vmin=-0.1, vmax=0.8)
at = AnchoredText(&quot;texts&quot;,
                  prop=dict(size=12), frameon=True,
                  loc='upper left',borderpad=0.05,
                  )
#at.patch.set_boxstyle(&quot;round, pad=0.,rounding_size=0.2&quot;)
at.patch.set_alpha(0.5)
at.patch.set_edgecolor([1, 1, 1, 0.5])
at.patch.set_linewidth(1)
ax.add_artist(at)

fig.savefig('test.pdf', dpi=300)
fig.savefig('test.png', dpi=300, transparent=False) "><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">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">from</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">offsetbox</span> <span class="pl-k">import</span> <span class="pl-v">AnchoredText</span>

<span class="pl-s1">fig</span>, <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>(<span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-s1">figsize</span><span class="pl-c1">=</span>(<span class="pl-c1">3.2</span>, <span class="pl-c1">3.2</span>))

<span class="pl-s1">ax</span>.<span class="pl-en">imshow</span>(<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">rand</span>(<span class="pl-c1">100</span> ,<span class="pl-c1">100</span>), <span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s">'Blues'</span>, <span class="pl-s1">vmin</span><span class="pl-c1">=</span><span class="pl-c1">-</span><span class="pl-c1">0.1</span>, <span class="pl-s1">vmax</span><span class="pl-c1">=</span><span class="pl-c1">0.8</span>)
<span class="pl-s1">at</span> <span class="pl-c1">=</span> <span class="pl-v">AnchoredText</span>(<span class="pl-s">"texts"</span>,
                  <span class="pl-s1">prop</span><span class="pl-c1">=</span><span class="pl-en">dict</span>(<span class="pl-s1">size</span><span class="pl-c1">=</span><span class="pl-c1">12</span>), <span class="pl-s1">frameon</span><span class="pl-c1">=</span><span class="pl-c1">True</span>,
                  <span class="pl-s1">loc</span><span class="pl-c1">=</span><span class="pl-s">'upper left'</span>,<span class="pl-s1">borderpad</span><span class="pl-c1">=</span><span class="pl-c1">0.05</span>,
                  )
<span class="pl-c">#at.patch.set_boxstyle("round, pad=0.,rounding_size=0.2")</span>
<span class="pl-s1">at</span>.<span class="pl-s1">patch</span>.<span class="pl-en">set_alpha</span>(<span class="pl-c1">0.5</span>)
<span class="pl-s1">at</span>.<span class="pl-s1">patch</span>.<span class="pl-en">set_edgecolor</span>([<span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">0.5</span>])
<span class="pl-s1">at</span>.<span class="pl-s1">patch</span>.<span class="pl-en">set_linewidth</span>(<span class="pl-c1">1</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">add_artist</span>(<span class="pl-s1">at</span>)

<span class="pl-s1">fig</span>.<span class="pl-en">savefig</span>(<span class="pl-s">'test.pdf'</span>, <span class="pl-s1">dpi</span><span class="pl-c1">=</span><span class="pl-c1">300</span>)
<span class="pl-s1">fig</span>.<span class="pl-en">savefig</span>(<span class="pl-s">'test.png'</span>, <span class="pl-s1">dpi</span><span class="pl-c1">=</span><span class="pl-c1">300</span>, <span class="pl-s1">transparent</span><span class="pl-c1">=</span><span class="pl-c1">False</span>) </pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>

<p dir="auto">pdf:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/15790176/110589554-8e358a00-81b1-11eb-9f02-8b78ead25127.png"><img src="https://user-images.githubusercontent.com/15790176/110589554-8e358a00-81b1-11eb-9f02-8b78ead25127.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">png:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/15790176/110589579-9a214c00-81b1-11eb-9b43-cc2c73959740.png"><img src="https://user-images.githubusercontent.com/15790176/110589579-9a214c00-81b1-11eb-9b43-cc2c73959740.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">PNG output has extra lines around the text, which is undesired.</p>
<p dir="auto"><strong>Expected outcome</strong></p>


<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system: Windows 10</li>
<li>Matplotlib version (<code class="notranslate">import matplotlib; print(matplotlib.__version__)</code>): 3.3.4</li>
<li>Matplotlib backend (<code class="notranslate">print(matplotlib.get_backend())</code>): Qt5Agg</li>
<li>Python version:  3.7</li>
<li>Jupyter version (if applicable):</li>
<li>Other libraries:</li>
</ul>