This should be simple, but I haven\'t found it: I have a value (the coefficient R squared) previously calculated and I want to insert it in a legend in matplotlib. If the value
You could just use string formatting :
plt.plot(x, y, linestyle='solid', color='k', label="Fitting line with $R^{{2}} = {}".format(r_squared))