gpt4 book ai didi

r - 绘制线条而不是点 R

转载 作者:行者123 更新时间:2023-12-04 12:06:32 26 4
gpt4 key购买 nike

这可能是一个简单的问题,但我无法找到解决方案。

我有以下图(我正在使用 plot CI,因为我无法用 plot() 填充点)。

leg<-c("1","2","3","4","5","6","7","8")
Col.rar1<-c(rgb(1,0,0,0.7), rgb(0,0,1,0.7), rgb(0,1,1,0.7),rgb(0.6,0,0.8,0.7),rgb(1,0.8,0,0.7),rgb(0.4,0.5,0.6,0.7),rgb(0.2,0.3,0.2,0.7),rgb(1,0.3,0,0.7))
library(plotrix)
plotCI(test$size,test$Mean,
pch=c(21), pt.bg=Col.rar1,xlab="",ylab="", ui=test$Mean,li= test$Mean)
legend(4200,400,legend=leg,pch=c(21),pt.bg=Col.rar1, bty="n", cex=1)

enter image description here

我想创建相同的效果,但使用线条而不是点(续行)

有什么建议吗?

最佳答案

您有 2 个解决方案:

  • 使用 lines()函数在 (x, y) 位置之间画线。
  • 使用 plottype = "l"喜欢线

  • 没有可重现的例子很难展示它,但你可以做例如:
    Col.rar1<-c(rgb(1,0,0,0.7), rgb(0,0,1,0.7), rgb(0,1,1,0.7),rgb(0.6,0,0.8,0.7),rgb(1,0.8,0,0.7),rgb(0.4,0.5,0.6,0.7),rgb(0.2,0.3,0.2,0.7),rgb(1,0.3,0,0.7))

    x <- seq(0, 5000, length.out=10)
    y <- matrix(sort(rnorm(10*length(Col.rar1))), ncol=length(Col.rar1))
    plot(x, y[,1], ylim=range(y), ann=FALSE, axes=T,type="l", col=Col.rar1[1])

    lapply(seq_along(Col.rar1),function(i){
    lines(x, y[,i], col=Col.rar1[i])
    points(x, y[,i]) # this is optional
    })

    enter image description here

    关于r - 绘制线条而不是点 R,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14100897/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com