It is easy to get a linear best fit of data in plotnine --using stat_smooth(method="gls")
. However, I can't figure out how to get out the coefficients to the best fit line or the R2 value. Ggplot in R has a stat_regline_equation()
function that does this, but I cannot find a similar tool in plotnine.
Currently, I am using statsmodels.formula.api.ols
to get these values, but there has to be a better way inside of plotnine.
PS: I'm a newbie to all things coding.