title: Reset default matplotlib colormap values after using 'set_under' or 'set_over'
body: <p>This is something that has been bugging me for a while. Whenever I use the <code>cmap.set_under()</code> or <code>cmap.set_over()</code> methods to change the the color of out of bound values, they seem to apply these changes to ALL instances where I use that colormap. Below is an example of what I am referring to.</p>
  
  <pre><code>import matplotlib.pyplot as plt 
  import numpy as np
  
  rand_data = np.random.randint(50, size=(20,20))
  
  plt.figure()
  plt.subplot(211)
  cmap1 = plt.cm.rainbow
  im1 = plt.pcolormesh(rand_data, cmap=cmap1, vmin=10)
  im1.cmap.set_under('w')
  plt.colorbar(extend='min')
  
  plt.subplot(212)
  cmap2 = plt.cm.rainbow
  im2 = plt.pcolormesh(rand_data, cmap=cmap2, vmin=10)
  im2.cmap.set_under('k')
  plt.colorbar(extend='min')
  
  plt.show()
  </code></pre>
  
  <p>Here I am trying to create two plots of the same values. In the first plot, I want all values below 10 to be white. In the second plot, I want all values below 10 to be black. The result is this:</p>
  
  <p><a href="https://i.stack.imgur.com/ABj1p.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ABj1p.png" alt=""></a></p>
  
  <p>It appears that the second time I used <code>set_under</code> it reset the set_under for all existing plots that use the rainbow colormap. If I use a different colormap in the second plot, I able to set a different <code>set_under</code> color:</p>
  
  <p><a href="https://i.stack.imgur.com/pykFl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pykFl.png" alt="enter image description here"></a></p>
  
  <p>Even more bizarre, if use <code>cmap.set_under()</code> or <code>cmap.set_over()</code> in a function or script, this setting does not reset after exiting that function. That is, if I comment out the lines where I explicitly defined the <code>set_under</code> and colors re-run my script, I get the same result as before.</p>
  
  <p>So I have a couple questions: </p>
  
  <ol>
  <li><p>Is there a way to set the color of out-of-bounds values of a colormap for a single plot <em>without affecting the colormap of any existing plots</em>? </p></li>
  <li><p>How do I reset the out-of-bounds values to their original colors? </p></li>
  </ol>
  
  <p>For the second question, I know I can manually add back in the original colors by doing something like this:</p>
  
  <pre><code>N = cmap.N
  cmap.set_under(cmap(1))
  cmap.set_over(cmap(N-1))
  </code></pre>
  
  <p>But, I feel like there should be an easier way.</p>