title: How can I change the color of an histogram label icon?
body: <p>Here's the code. However, the histogram has a black icon as a label. How can I change it to red or to the gradient of colors 'hot'. I know I changed the bars colors to that of the gradient 'hot' however I don't want a black label for the histogram since I want to distinguish it from the analytical one.</p>
  
  <pre><code>import math, matplotlib.pyplot as plt, random 
  
  def probability(x):
  
      #wavefunction n=0 evaluated at position x
      psi_0_x=math.exp(-x ** 2 / 2.0) / math.pi ** 0.25
  
      #probability n=0 to be at position x
      psi_0_x_squared= psi_0_x**2
  
      return psi_0_x_squared
  
  data_x=[0]
  x = 0.0        #starts at position 0
  delta = 0.5    #stepsize
  trial_steps=1000000
  
  for t in range(trial_steps):
  
      #displace x by delta
      x_new = x + random.uniform(-delta, delta) 
  
      #selecciono un numero entre 0 y 1 (incluye acceptance y rejection probability). Metropolis!
      #probabilidad de estar en nuevo sitio/probabilidad de quedarme en el sitio anterior 
      if random.uniform(0.0, 1.0) &lt; probability(x_new)/probability(x):
  
          #me muevo si la condicion es cierta (está en el accepted range)
          x = x_new 
      data_x.append(x)
  
  #histogram
  cm = plt.cm.get_cmap('hot') 
  n, bins, patches= plt.hist(data_x, bins=100, normed=True, color='r',label='Histogram')
  for height, p in zip(n, patches):
      plt.setp(p, 'facecolor', cm(height))
  
  plt.xlabel('x')
  plt.ylabel('$Probability =|\psi_0(x)|^2$')
  
  #general analytical formula
  x_grid = [a / 100.0 for a in range(-300,301)]
  Prob = [probability(position) for position in x_grid]
  plt.plot(x_grid, Prob, linewidth=1.5, color='k', label='Analytical')
  
  plt.title("Position's probability density $|\psi_0(x)|^2$ for a harmonic oscillator.")
  plt.savefig('ground_probability_x.png')
  plt.legend()
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/WANst.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WANst.png" alt="enter image description here"></a></p>