繁体   English   中英

在图表上打印 R 中的最佳拟合线方程

[英]Print the best fit line equation in R on the chart

在此处输入图片说明

嗨,我在 python 中使用 matplotlib 创建了下面的图表。 该图显示了每个组的最佳拟合线。

我想在 R 中复制相同的过程并在每条线的顶部打印最佳拟合线方程,请提出建议。

你的问题有点含糊。

我知道的一个内置 R 函数是abline()

引用?abline()帮助命令。

Description

This function adds one or more straight lines through the current plot. Usage

abline(a = NULL, b = NULL, h = NULL, v = NULL, reg = NULL,
       coef = NULL, untf = FALSE, ...)

Arguments a, b  

the intercept and slope, single values. untf    

logical asking whether to untransform. See ‘Details’. h     

the y-value(s) for horizontal line(s). v    

the x-value(s) for vertical line(s). coef   

a vector of length two giving the intercept and slope. reg  

an object with a coef method. See ‘Details’. ...    

graphical parameters such as col, lty and lwd (possibly as vectors: see ‘Details’) and xpd and the line characteristics lend, ljoin and lmitre.

abline示例图像例子

这不是您真正要求的,因为它会产生直线。 但这已经是最合适的线了。

您还可以探索一般的?lines ,看看自己最适合什么。

另一个建议是简单地展示您的代码示例,以便我们可以看到您做了什么,并提出有关在 R 中实现的想法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM