[Tutor] Matplotlib.pyplot - How to Insert Computed values in Plot Legend
Stephen P. Molnar
s.molnar at sbcglobal.net
Sat Oct 24 08:50:21 EDT 2020
I have written a Python script to plot Linear Regression results using
python-3.7.3 with matplotlib-3.3.0 on my Debian Buster platform.
The script also calculates a number of statistical parameters as well as
the slope (b-sub-1) and intercept (b-sub-0) of the regression line.
However, there remain several problems for which I have not be able to
find a solution, in spite of Google.
The code for the plot legend at this point is:
red_patch = mpatches.Patch(label='A = b$_1$*log(IC$_5$$_0$) - b$_0$
\nr$^2$ = ')
.
.
.
plt.legend(handles=[red_patch], loc='lower right', frameon=False)
1. How can I insert formatted values for the slope, intercept i and r-sq
in the legend?
2. How can I change the blue line in the legend to the same thickness of
the regression line?
I would greatly appreciate assistance in resolving these problems.
Thanks in advance.
--
Stephen P. Molnar, Ph.D.
www.molecular-modeling.net
614.312.7528 (c)
Skype: smolnar1
More information about the Tutor
mailing list