[英]R how to respectively add regression lines for two groups of points in two-y-axis plot using the plotrix package
[英]White lines in gradient.rect from R's plotrix package
有人有解决方案,可以删除在图顶部渐变矩形中看到的白线吗? 这些是从plotrix
包中使用gradient.rect
生产的。
gradient.rect(as.Date("1979-05-04"),70,as.Date("1990-11-28"),80,col=smoothColors("royalblue",100.0,"white"),border=NA,gradient="x")
它们既出现在RStudio的输出中,也出现在导出的PNG中。
我可以使用以下代码重现问题(尽管不是该图像):
png();plot(x=seq(as.Date("1979-05-04"),as.Date("1990-11-28"),length=50),
1:50,type="n",axes=FALSE) # set up plot coords correctly
plotrix::gradient.rect(as.Date("1979-05-04"),5, as.Date("1990-11-28"),6,
col=plotrix::smoothColors("royalblue", 100.0,"white"),
border=NA,gradient="x",nslices=121);
dev.off()
然后我看到了三个细的白色垂直条带。 我查看了RGB值并绘制了它们的十六进制等效项:
plot(NA, xlim=c(1,110),ylim=c(0x4169E1, 0xFFFFFF) )
lines(1:102, as.numeric(
paste0('0x',
substr( plotrix::smoothColors("royalblue",100.0,"white"),
2,7)
) ) )
我注意到序列中存在不均匀的间隙,因此尝试使用更少的颜色获得更好的成功:
png(); plot(x=seq(as.Date("1979-05-04"),as.Date("1990-11-28"),length=50),1:50,type="n",axes=FALSE)
plotrix::gradient.rect(as.Date("1979-05-04"),20,as.Date("1990-11-28"),30,
col=plotrix::smoothColors("royalblue",55,"white"),border=NA,gradient="x");dev.off()
我真的不明白为什么会这样。 如果您需要解释...而不只是解决策略,可以与Jim Lemon联系。 如果您键入以下内容,则他的电子邮件地址应显示在R控制台上: maintainer("plotrix")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.