首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >理解带有“jitter”的boxplot

理解带有“jitter”的boxplot
EN

Stack Overflow用户
提问于 2015-07-26 02:57:31
回答 1查看 7.5K关注 0票数 1

我正在处理一个大型数据集,研究几个地理区域的疾病病例,其中一个预测因素是百里香。我试着创建带有抖动的盒子图,但无法很清楚地解释它。有人能帮上忙吗?

代码如下:

代码语言:javascript
复制
ggplot(factor(Region), Cases, data=orf, geom=c("boxplot", "jitter"),                            
      main=" Cases by Thistles and Regions",fill=factor(Thistles),                          
      xlab="Regions", ylab="Number of cases")

这是一个非常大的数据集,所以这里只是一小部分:

代码语言:javascript
复制
Region  Thistles    Cases
    1   1           40
    1   2           0
    1   1           8
    1   3           73
    1   3           0
    1   1           26
    1   2           0
    1   1           45
    1   4           0
    1   4           22
    1   0           0
    2   3           46
    1   0           10
    2   1           6
    2   1           539
    2   1           0
    2   2           0
    2   1           60
    2   1           0
    2   1           10
    2   3           0
    2   3           29
    3   2           0
    3   4           35
    3   3           100
    3   2           0
    3   1           550
    3   2           0
    3   3           1
    3   5           67
    3   1           0
    3   2           90

EN

回答 1

Stack Overflow用户

发布于 2015-07-26 04:48:54

这些图表说明了@R RHertel在评论中提出的观点。

代码语言:javascript
复制
library(ggplot2)

p1 = ggplot(iris, aes(x=Species, y=Sepal.Length)) +
     geom_point(aes(fill=Species), size=5, shape=21, colour="grey20") +
     geom_boxplot(outlier.colour=NA, fill=NA, colour="grey20") +
     labs(title="Not Jittered")


p2 = ggplot(iris, aes(x=Species, y=Sepal.Length)) +
     geom_point(aes(fill=Species), size=5, shape=21, colour="grey20",
                position=position_jitter(width=0.2, height=0.1)) +
     geom_boxplot(outlier.colour=NA, fill=NA, colour="grey20") +
     labs(title="Jittered")

library(gridExtra)
png("jittering.png", height=5, width=10, units="in", res=100)
grid.arrange(p1, p2, nrow=1)
dev.off()
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31630045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档