title: Can I colour a seaborn distplot by values in another variable?
body: <p>I would like to colour a <code>seaborn.distplot</code> by another variable in my dataframe. </p>
  
  <p>Here's an abstracted example:</p>
  
  <pre><code>import numpy
  import pandas
  import seaborn
  A = numpy.random.choice(100, size=1000)
  B =  numpy.random.choice(1000, size=1000)
  df = pandas.DataFrame([A, B], index=['A', 'B']).transpose()
  df = df.sort_values(by='B')
  plt.figure()
  seaborn.distplot(df['A'], bins=50)
  plt.show()
  </code></pre>
  
  <p>Which produces:
  <a href="https://i.stack.imgur.com/quxWP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/quxWP.png" alt="enter image description here"></a></p>
  
  <p>Is it possible to now colour this plot based on the values in<code>df['B']</code>?</p>
  
  <hr>
  
  <h2>edit</h2>
  
  <p>To clarify, Lets say that <code>A</code> is the distribution of peoples age and <code>B</code> is their weight. I'd like a gradient of colours such that bars of the histogram are coloured (say) green if older people are also heavy. Note that I'm not expecting a nice spectrum - the 'interesting data' may well appear in the middle of the plot. For me interesting data are <code>A</code>'s which have a low <code>B</code>. </p>
  
  <p>I hope that clears things up.</p>