【问题标题】:How do I set the regression line color in the r car scatterplotMatrix function如何在 r car scatterplotMatrix 函数中设置回归线颜色
【发布时间】:2019-11-06 13:53:30
【问题描述】:

r car scatterplotMatrix函数中如何改变回归线的颜色?

如果我运行这段代码:

# Load the iris dataset.
library(car)
data(iris)
 
# Plot #1: Basic scatterplot matrix of the four measurements
scatterplotMatrix(~Sepal.Length+Sepal.Width+Petal.Length+Petal.Width, data=iris)

然后我得到这个情节:

检查显示点、平滑窗口和回归线都是相同的颜色,并且没有很明显的区别。

如果我想要蓝色的点、绿色的回归和橙色的平滑,我该怎么做?

【问题讨论】:

    标签: r plot colors


    【解决方案1】:

    这只需要仔细阅读文档?scatterplotMatrix

    关于颜色的部分说:

    col
    点的颜色;默认是 carPalette 从 第二种颜色。 regLine 和 smooth 的颜色与 for 相同 点but can be changed using the the regLine and smooth arguments.

    regLine的描述说:

    regLine=TRUE 等价于 regLine = list(method=lm, lty=1, lwd=2, col=col[1])

    smooth 更复杂。描述在详细信息部分。该描述很长,但包括:

    您还可以指定要用于均值和 使用参数 col.smooth 和 col.spread 平滑方差。

    把这一切放在一起,你可以得到

    scatterplotMatrix(~Sepal.Length+Sepal.Width+Petal.Length+Petal.Width, 
        data=iris, regLine = list(col="green"),
        smooth=list(col.smooth="orange", col.spread="orange"))
    

    【讨论】:

    • 文档并不是很明确。谁告诉我col.smoothcol.spread 参数不能在scatterplotMatrix 中使用,而不是在smooth = list(...) 中使用。
    猜你喜欢
    • 2013-12-29
    • 2012-01-04
    • 2018-02-25
    • 2022-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-28
    • 1970-01-01
    相关资源
    最近更新 更多