点图“分箱/分组”在R中
我有 5 个数据集,每个数据集都有一个值列和一个组列。
每个数据集都有不同的“组”值。 它们连接在一起形成 1 个大数据集,每个数据集都由其“组”值清楚地分隔开
由于大多数数据点位于 2-3 范围内,因此它们彼此堆叠,结果绘图的数据点溢出到其他组
这是我当前使用的绘图代码:
p<-ggplot(new_df, aes(x=group, y=ploidy)) +
geom_dotplot(binaxis='y', stackdir='centerwhole', binwidth = 0.5, position = "dodge", stackgroups = TRUE, dotsize = 0.2)
ggplot(new_df, aes(x=group, y=ploidy)) +
geom_dotplot(binaxis='y', stackdir='centerwhole',
stackratio=1.5, dotsize=0.2, stackgroups = TRUE)
p + scale_x_discrete(limits=c("1", "2", "3", "4", "5"))
p + stat_summary(fun=median, geom="point", shape=18,
size=3, color="red")
任何人都可以帮助指出我犯了什么错误以及如何修复它?我尝试过调整许多不同的参数并遵循文档,但 R 不是我的主要语言,我遇到了麻烦。 任何帮助将不胜感激,谢谢。
I have 5 datasets, each with a value column and a group column.
Each dataset has a different 'group' value.
They're joined together to make 1 big dataset, each clearly separated by its 'group' value
I'm trying to create a dotplot that neatly separates the groups by themselves, kind of like the following, where the M and F groups are clearly separated:
What I currently have, however, is the following:
Since most of the datapoints sit around the 2-3 range, they are stacked above each other and the resulting plot has datapoints that are overflowing to the other groups
This is the plotting code I'm currently using:
p<-ggplot(new_df, aes(x=group, y=ploidy)) +
geom_dotplot(binaxis='y', stackdir='centerwhole', binwidth = 0.5, position = "dodge", stackgroups = TRUE, dotsize = 0.2)
ggplot(new_df, aes(x=group, y=ploidy)) +
geom_dotplot(binaxis='y', stackdir='centerwhole',
stackratio=1.5, dotsize=0.2, stackgroups = TRUE)
p + scale_x_discrete(limits=c("1", "2", "3", "4", "5"))
p + stat_summary(fun=median, geom="point", shape=18,
size=3, color="red")
Can anyone help point out what mistake I'm making and how to fix it? I've tried tweaking many different parameters and following the documentation but R isn't my main language and I'm running into trouble.
Any help would be appreciated, thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论