title: How to make a legend with r-values and regression function in matplotlib (python)?
body: <p>Following code:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  from scipy import stats
  
  x=np.linspace(2.0, 3.0, num=100)*1e-5
  y=np.linspace(2.0, 3.0, num=100)*1e3
  
  slope, intercept, r_value, p_value, std_err = stats.linregress(x,y)
  predict_y = intercept + slope * x
  
  plt.plot(x,y,'go')
  plt.plot(x, predict_y, 'k-')
  plt.legend(('data', 'line-regression'), 'upper left')
  plt.autoscale(True)
  plt.grid(True)
  plt.show()
  </code></pre>
  
  <p>I can plot it, I can find the r-value, I can do a linear regression and show it on the plot. What I am too stupid to do is to write it on the graph. Maybe you can help?</p>
  
  <p>So that the function and the r-value is shown as an own legend or in the legend or what you experts find best.</p>
  
  <p>Kind regards! And ty very much in advance!</p>
  
  <p>PS! If you know a better way to solve my problem, I would be very happy with it too :-)</p>