title: How can I convert a seaborn color palette into a cmap?
body: <p>I would like to convert the <em>continuous</em> diverging color palette "RdBu_r" (or really, any pre-defined color palette) in seaborn into a matplotlib colormap. </p>
  
  <p>This is the closest I've come, but it creates a discrete color map, whereas I would like a continuous map:</p>
  
  <pre><code>import seaborn as sns
  from matplotlib.colors import ListedColormap
  
  palette = sns.color_palette("RdBu_r", n=7) # could make n = 100 as a quick fix
  cmap = ListedColormap(colors=palette)
  cmap.set_bad(color='black', alpha=0.5)
  sns.heatmap(cmap=cmap) 
  </code></pre>
  
  <p>Ultimately, I am trying to create a seaborn heatmap with the "RdBu_r" color palette, with null values filled in as dark squares, which is why I am trying to create a cmap with set_bad(color='black'), as opposed to just passing in "RdBu_r" into the cmap argument of sns.heatmap. </p>
  
  <p>Thanks guys. </p>