我得到这个图形,但是我想将每条回归直线的公式也用标签在图像中显示,请问各位,怎么解决呀!谢谢了
参考以下例子,如果要写复杂的公式,用Latex标记, Text rendering With LaTeX — Matplotlib 3.4.3 documentation https://matplotlib.org/stable/tutorials/text/usetex.html
import seaborn as sns
import matplotlib.pyplot as plt
from scipy import stats
tips = sns.load_dataset("tips")
# get coeffs of linear fit
slope, intercept, r_value, p_value, std_err = stats.linregress(tips['total_bill'],tips['tip'])
# use line_kws to set line label for legend
ax = sns.regplot(x="total_bill", y="tip", data=tips, color='b',
line_kws={'label':"y={0:.1f}x+{1:.1f}".format(slope,intercept)})
# plot legend
ax.legend()
plt.show()