title: How does imshow handle the alpha channel with an M x N x 4 input?
body: <p>GH issue <a href="http://github.com/matplotlib/matplotlib/issues/3343" rel="noreferrer">#3343</a></p>
  
  <hr>
  
  <p>I am using the <code>imshow</code> function in matplotlib to visualize some data. What I have are two arrays, <em>A</em> and <em>B</em>, that are the same size. I would like to use a colormap to show scalar values in <em>A</em>, and I would like to use the alpha channel to show the scalar values in <em>B</em>. In other words, if the value at a given coordinate in both <em>A</em> and <em>B</em> is large, then the pixel in the plot will be bright green and opaque. If it is large in <em>A</em> and not <em>B</em>, then it will be bright green but mostly transparent. And if it is large in <em>B</em> and not <em>A</em>, then it will be opaque but white.</p>
  
  <p>However, the resulting image is not what I am expecting. My input data is called <code>d</code>, and it is a combination of the RGB values that result from mapping the <em>A</em> array with a matplotlib colormap (i.e. <code>mpl.cm.BuGn(A)</code>) and the <em>B</em> array.</p>
  
  <p>Here I'm going to plot the full image (what I want to actually use), the RGB image (<em>A</em>, mapped with <code>BuGn</code>), and the alpha-providing array (<em>B</em>, with a grayscale colormap).</p>
  
  <pre><code>f, (ax0, ax1, ax2) = plt.subplots(1, 3, figsize=(5, 2.5))
  
  ax0.imshow(d)
  ax1.imshow(d[..., :-1])
  ax2.imshow(d[..., -1])
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Z5zLb.png" alt="enter image description here"></p>
  
  <p>I am confused about where the splotchy gray junk in the full image is coming from, since there aren't any values in the colormap that are those colors. To show this effect more dramatically, I can change the bounds of the colormap so they are far away from the extremes of the data and re-plot:</p>
  
  <p><img src="https://i.stack.imgur.com/23W4s.png" alt="enter image description here"></p>
  
  <p>I don't understand why pixels that are white with a large alpha value show up as gray. Opaque white should still be white.</p>
  
  <p>Note that this behavior is different than if I plot the RGB component array and lower the transparancy with the <code>alpha</code> kwarg, i.e. <code>ax2.imshow(d[..., :-1], alpha=.3)</code>:</p>
  
  <p><img src="https://i.stack.imgur.com/6Hj0t.png" alt="enter image description here"></p>