title: How to plot a stacked histogram with two arrays in python
body: <p>I am trying to create a stacked histogram showing the clump thickness for malignant and benign tumors, with the malignant class colored red and the benign class colored blue. </p>
  
  <p>I got the clump_thickness_array and benign_or_malignant_array. The benign_or_malignant_array consists of 2s and 4s.</p>
  
  <ol>
  <li>If benign_or_malignant equals 2 it is benign(blue colored). </li>
  <li>If it equals 4 it is malignant(red colored).</li>
  </ol>
  
  <p>I can not figure out how to color the benign and malignant tumors. My Histogram is showing something other than what I try to achieve.</p>
  
  <p>This is my code and my histogram so far:</p>
  
  <pre><code>fig, ax = plt.subplots(figsize=(12,8))
  tmp = list()
  for i in range(2):
  indices = np.where(benign_or_malignant&gt;=i )
  tmp.append(clump_thickness[indices])
  
  ax.hist(tmp,bins=10,stacked=True,color = ['b',"r"],alpha=0.73)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/XHru8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XHru8.png" alt="enter image description here"></a></p>