title: Matplotlib transparent overlay & pdf transparency
body: <p>Let's assume I have two numpy arrays (The ones I present are just examples):</p>
  
  <pre><code>import numpy as np
  A = np.arange(144).reshape((12, 12))
  np.random.shuffle(A)
  
  B = np.ones((12,12))
  B[0:10:4,:] = None
  </code></pre>
  
  <p>I want to plot <b>A</b> using imshow:</p>
  
  <pre><code>import matplotlib.pyplot as mplt
  mplt.imshow(A, cmap = mplt.gray())
  </code></pre>
  
  <p>and overlay <b>B</b> so that the <i>None</i> areas are fully transparent and the <i>one</i> areas have an alpha of (e.g. alpha = 0.3.). </p>
  
  <p>I already tried using something along the lines of:</p>
  
  <pre><code>mplt.imshow(B, cmap = mplt.get_cmap('Reds), alpha = 0.3)
  </code></pre>
  
  <p>but that does not work. Also tried to use masked arrays to create B, but cannot get my head around it. Any suggestions?</p>
  
  <p>Thanks</p>
  
  <h1><b>EDIT:</b></h1>
  
  <p>I ended up using </p>
  
  <pre><code>my_red_cmap = mplt.cm.Reds
  my_red_cmap.set_under(color="white", alpha="0")
  </code></pre>
  
  <p>which works like a charm (I tested Bill's solution as well, which also works perfectly). </p>