gpt4 book ai didi

r - 如何绘制 fiddle 散点箱线图(在 R 中)?

转载 作者:行者123 更新时间:2023-12-02 07:47:05 25 4
gpt4 key购买 nike

我刚刚得到以下情节:

alt text

想知道如何在 R 中完成它? (或其他软件)

11.03.10更新:感谢所有参与回答此问题的人 - 你们提供了精彩的解决方案!我已经在 a post on my blog 中编译了此处提供的所有解决方案(以及我在网上找到的其他一些解决方案)。 .

最佳答案

Make.Funny.Plot 或多或少做了我认为它应该做的事情。根据您自己的需求进行调整,并且可能会进行一些优化,但这应该是一个不错的开始。

Make.Funny.Plot <- function(x){
unique.vals <- length(unique(x))
N <- length(x)
N.val <- min(N/20,unique.vals)

if(unique.vals>N.val){
x <- ave(x,cut(x,N.val),FUN=min)
x <- signif(x,4)
}
# construct the outline of the plot
outline <- as.vector(table(x))
outline <- outline/max(outline)

# determine some correction to make the V shape,
# based on the range
y.corr <- diff(range(x))*0.05

# Get the unique values
yval <- sort(unique(x))

plot(c(-1,1),c(min(yval),max(yval)),
type="n",xaxt="n",xlab="")

for(i in 1:length(yval)){
n <- sum(x==yval[i])
x.plot <- seq(-outline[i],outline[i],length=n)
y.plot <- yval[i]+abs(x.plot)*y.corr
points(x.plot,y.plot,pch=19,cex=0.5)
}
}

N <- 500
x <- rpois(N,4)+abs(rnorm(N))
Make.Funny.Plot(x)

编辑:已更正,因此它始终有效。

关于r - 如何绘制 fiddle 散点箱线图(在 R 中)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12496709/

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