title: Python Matplotlib: add legend with the exact value of a mean lien
body: <p>I have made a plot using matplotlib library, which depicts two histograms and the mean lines. I think that the plot would be more clear if I add the legend. I want to create a legend, which says what exact values have this two mean lines. Below I attache my code and the plot which I generated and the picture which shows what I want to achieve (it is picture where I added the legend using powerpoint):</p>
  
  <pre><code>def setPlot(data, mycolor, myalpha, mylinestyle):
      plt.style.use('ggplot')
      plt.rc('xtick',labelsize=12)
      plt.rc('ytick',labelsize=12)
      plt.xlabel("Incomes")
      plt.hist(data, bins=50, color= mycolor, alpha=myalpha)
      plt.axvline(numpy.mean(data), color=mycolor, linestyle=mylinestyle, linewidth=1.5)
      plt.show()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/XlPGJ.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/N8Nhu.png" alt="enter image description here"></p>
  
  <p>I will be grateful for any suggestions.</p>
  
  <p>-----------SOLUTION--------</p>
  
  <p>Thanks to the great advises from <strong>wwii</strong> and <strong>tom</strong> I was able to implement the solution to my idea. I have tried to concatenate both suggestions, and this is what I obtained:</p>
  
  <pre><code>def setPlot(data, mycolor, myalpha, mylinestyle):
      plt.style.use('ggplot')
      plt.rc('xtick',labelsize=12)
      plt.rc('ytick',labelsize=12)
      plt.xlabel("Incomes")
      plt.hist(data, bins=50, color= mycolor, alpha=myalpha)
      plt.axvline(numpy.mean(data), color=mycolor, linestyle=mylinestyle, linewidth=1.5, label=str(numpy.mean(data)))
      plt.legend(loc='upper right')
      plt.show()
  </code></pre>
  
  <p>And the example of my generated plot:
  <img src="https://i.stack.imgur.com/hQrAo.png" alt="enter image description here"></p>
  
  <p>Many thanks for all your help! </p>