楼主: 百年-树人
5993 2

[学习分享] scatterplot()等函数中lty.smooth的警告问题 [推广有奖]

  • 0关注
  • 1粉丝

本科生

65%

还不是VIP/贵宾

-

威望
0
论坛币
1420 个
通用积分
2.4744
学术水平
14 点
热心指数
23 点
信用等级
12 点
经验
1625 点
帖子
60
精华
0
在线时间
145 小时
注册时间
2015-10-26
最后登录
2020-12-28

相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
关于scatterplot()或scatterplotMatrix()函数,按照一些R语言的书籍所述,会出现如下类似的命令:
> scatterplotMatrix(~mpg+disp+drat+wt,data=mtcars,spread=F,lty.smooth=2,main="Scatter Plot Matrix via car Package")
而运行结果往往会出现如下警告:
There were 50 or more warnings (use warnings() to see the first 50)
警告信息:
1: In plot.window(...) : "lty.smooth"不是图形参数
2: In plot.xy(xy, type, ...) : "lty.smooth"不是图形参数
3: In title(...) : "lty.smooth"不是图形参数
4: In plot.window(...) : "lty.smooth"不是图形参数
5: In plot.xy(xy, type, ...) : "lty.smooth"不是图形参数
6: In title(...) : "lty.smooth"不是图形参数
7: In axis(side = side, at = at, labels = labels, ...) : "lty.smooth"不是图形参数
8: In plot.window(...) : "lty.smooth"不是图形参数

显然,lty.smooth=2这一参数设置并不会出现我们预期的效果。

现在,我们来看看scatterplotMatrix()函数的信息(参见“?scatterplotMatrix”)
scatterplotMatrix(x, var.labels=colnames(x),
         diagonal=c("density", "boxplot", "histogram", "oned", "qqplot", "none"),
         adjust=1, nclass,
         plot.points=TRUE, smoother=loessLine, smoother.args=list(), smooth, span,
         spread = !by.groups, reg.line=lm,
         transform=FALSE, family=c("bcPower", "yjPower"),
         ellipse=FALSE, levels=c(.5, .95), robust=TRUE,
         groups=NULL, by.groups=FALSE,
         use=c("complete.obs", "pairwise.complete.obs"),
         labels, id.method="mahal", id.n=0, id.cex=1, id.col=palette()[1],
         col=if (n.groups == 1) palette()[3:1] else rep(palette(), length=n.groups),
         pch=1:n.groups, lwd=1, lty=1,
         cex=par("cex"), cex.axis=par("cex.axis"), cex.labels=NULL,
         cex.main=par("cex.main"),
         legend.plot=length(levels(groups)) > 1, legend.pos=NULL, row1attop=TRUE, ...)
我们主要关注红色字体部分——smoother=loessLine, smoother.args=list()
其中,参数smoother指定了光滑曲线的绘制方法,默认采用loessLine()函数(关于该函数的具体信息参见“?loessLine”)来进行绘制。
而参数smoother.args=list()则指定了光滑曲线的线条长度,宽度等细节信息
loessLine()函数绘制的曲线的默认细节参数如下:
smoother.args=list(lty=1,
     lwd=2, lty.spread=2, lwd.spread=1, span=0.5, degree=2,
     family="symmetric", iterations=4)

所以,我们可以用参数smoother.args=list(lty=2)来实现lty.smooth=2所期望的效果。
即上述开始提出的命令可改写为:
> scatterplotMatrix(~mpg+disp+drat+wt,data=mtcars,spread=F,smoother.args=list(lty=2),main="Scatter Plot Matrix via car Package")
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:scatterplot Scatter smooth plot SCAT Matrix title 书籍 信息

决定了就不要后悔,走下去~~~
沙发
lion果 发表于 2019-1-21 22:50:21 |只看作者 |坛友微信交流群
scatterplot函数里 spread和smoother.args两个参数显示不是图形参数 目前用的3.5.2版本r 求教

F640FD1C-55B2-4CDB-A83F-53C7877B0BAF.jpeg (6.89 MB)

F640FD1C-55B2-4CDB-A83F-53C7877B0BAF.jpeg

已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
admin_kefu + 30 + 2 + 2 + 2 热心帮助其他会员

总评分: 论坛币 + 30  学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

使用道具

藤椅
HaoYAN 在职认证  发表于 2019-2-6 21:56:37 |只看作者 |坛友微信交流群
lion果 发表于 2019-1-21 22:50
scatterplot函数里 spread和smoother.args两个参数显示不是图形参数 目前用的3.5.2版本r 求教
最新的帮助:
?scatterplotMatrix

## Default S3 method:
scatterplotMatrix(x, smooth = TRUE,
    id = FALSE, legend = TRUE, regLine = TRUE,
    ellipse = FALSE, var.labels = colnames(x), diagonal = TRUE,
    plot.points = TRUE, groups = NULL, by.groups = TRUE,
    use = c("complete.obs", "pairwise.complete.obs"), col =
    carPalette()[-1], pch = 1:n.groups, cex = par("cex"),
    cex.axis = par("cex.axis"), cex.labels = NULL,
    cex.main = par("cex.main"), row1attop = TRUE, ...)


在R 语言实战中的8.2 OLS回归中
图8-3的语法是不对了。没有spread=FALSE,smoother.args=list(lty=2)的定义。
可以通过下面的语句实现:

scatterplot(weight
  ~ height, data = women, smooth=list(spread=FALSE,
  lty.smooth=2))

即为上面两个参数包含在smooth参数中。




已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
admin_kefu + 30 + 3 + 3 + 3 热心帮助其他会员

总评分: 论坛币 + 30  学术水平 + 3  热心指数 + 3  信用等级 + 3   查看全部评分

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-6-16 16:00