<h3 dir="auto">Bug summary</h3>
<p dir="auto"><code class="notranslate">contourf()</code> by default does not draw borders between adjacent levels.  However, including the <code class="notranslate">alpha</code> keyword argument makes these borders visible.  Desired behavior is to not draw these lines even with <code class="notranslate">alpha</code> specified.</p>
<h3 dir="auto">Code for reproduction</h3>
<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.linspace(-3, 5, 150).reshape(1, -1)
y = np.linspace(-3, 5, 120).reshape(-1, 1)
z = np.cos(x) + np.sin(y)
x, y = x.flatten(), y.flatten()
fig, ax = plt.subplots(nrows=2,ncols=1)
ax[0].set_title('Actual outcome')
ax[0].contourf(x, y, z, levels=15, vmin=0.5, vmax=1.0, cmap='cividis', alpha=0.9)
ax[1].set_title('Expected outcome')
ax[1].contourf(x, y, z, levels=15, vmin=0.5, vmax=1.0, cmap='cividis')
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">linspace</span>(<span class="pl-c1">-</span><span class="pl-c1">3</span>, <span class="pl-c1">5</span>, <span class="pl-c1">150</span>).<span class="pl-en">reshape</span>(<span class="pl-c1">1</span>, <span class="pl-c1">-</span><span class="pl-c1">1</span>)
<span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">-</span><span class="pl-c1">3</span>, <span class="pl-c1">5</span>, <span class="pl-c1">120</span>).<span class="pl-en">reshape</span>(<span class="pl-c1">-</span><span class="pl-c1">1</span>, <span class="pl-c1">1</span>)
<span class="pl-s1">z</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">cos</span>(<span class="pl-s1">x</span>) <span class="pl-c1">+</span> <span class="pl-s1">np</span>.<span class="pl-en">sin</span>(<span class="pl-s1">y</span>)
<span class="pl-s1">x</span>, <span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span>.<span class="pl-en">flatten</span>(), <span class="pl-s1">y</span>.<span class="pl-en">flatten</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-s1">nrows</span><span class="pl-c1">=</span><span class="pl-c1">2</span>,<span class="pl-s1">ncols</span><span class="pl-c1">=</span><span class="pl-c1">1</span>)
<span class="pl-s1">ax</span>[<span class="pl-c1">0</span>].<span class="pl-en">set_title</span>(<span class="pl-s">'Actual outcome'</span>)
<span class="pl-s1">ax</span>[<span class="pl-c1">0</span>].<span class="pl-en">contourf</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>, <span class="pl-s1">z</span>, <span class="pl-s1">levels</span><span class="pl-c1">=</span><span class="pl-c1">15</span>, <span class="pl-s1">vmin</span><span class="pl-c1">=</span><span class="pl-c1">0.5</span>, <span class="pl-s1">vmax</span><span class="pl-c1">=</span><span class="pl-c1">1.0</span>, <span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s">'cividis'</span>, <span class="pl-s1">alpha</span><span class="pl-c1">=</span><span class="pl-c1">0.9</span>)
<span class="pl-s1">ax</span>[<span class="pl-c1">1</span>].<span class="pl-en">set_title</span>(<span class="pl-s">'Expected outcome'</span>)
<span class="pl-s1">ax</span>[<span class="pl-c1">1</span>].<span class="pl-en">contourf</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>, <span class="pl-s1">z</span>, <span class="pl-s1">levels</span><span class="pl-c1">=</span><span class="pl-c1">15</span>, <span class="pl-s1">vmin</span><span class="pl-c1">=</span><span class="pl-c1">0.5</span>, <span class="pl-s1">vmax</span><span class="pl-c1">=</span><span class="pl-c1">1.0</span>, <span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s">'cividis'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1459933/185768358-a54285fc-8e9a-4d84-a1f3-d962888d31e2.png"><img src="https://user-images.githubusercontent.com/1459933/185768358-a54285fc-8e9a-4d84-a1f3-d962888d31e2.png" alt="actual" style="max-width: 100%;"></a></p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1459933/185768363-521351d6-ecb4-4745-aee6-7d1afc06a94a.png"><img src="https://user-images.githubusercontent.com/1459933/185768363-521351d6-ecb4-4745-aee6-7d1afc06a94a.png" alt="expected" style="max-width: 100%;"></a></p>
<h3 dir="auto">Additional information</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">Ubuntu 20.04</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.5.1</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">QtAgg</p>
<h3 dir="auto">Python version</h3>
<p dir="auto">3.8.8</p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Installation</h3>
<p dir="auto">conda</p>
<p dir="auto">This is the underlying problem raised in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="6572843" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/1178" data-hovercard-type="pull_request" data-hovercard-url="/matplotlib/matplotlib/pull/1178/hovercard" href="https://github.com/matplotlib/matplotlib/pull/1178">#1178</a>.<br>
It is illustrated by the test below; note that boundary anomalies are visible in all forms--agg on the screen, and pdf and svg displayed with a viewer--but in different places depending on the viewer and the size of the figure as rendered.<br>
Note that the colorbar is rendered using pcolormesh, which has its own renderer with agg but otherwise is handled by draw_path_collection.</p>
<pre class="notranslate">import numpy as np
import matplotlib.pyplot as plt

z = np.arange(150)
z.shape = (10,15)

fig, axs = plt.subplots(2,2)

ax = axs[0,0]
cs0 = ax.contourf(z, 20)
cbar0 = fig.colorbar(cs0, ax=ax)

ax = axs[0,1]
cs1 = ax.contourf(z, 20, alpha=0.3)
cbar1 = fig.colorbar(cs1, ax=ax)

ax = axs[1,0]
im2 = ax.imshow(z, interpolation='nearest')
cbar2 = fig.colorbar(im2, ax=ax)

ax = axs[1,1]
im3 = ax.imshow(z, interpolation='nearest', alpha=0.3)
cbar3 = fig.colorbar(im3, ax=ax)

plt.savefig("test1.pdf")
plt.savefig("test1.svg")
plt.show()
</pre>