[英]How to more effectively plot points in ggplot2 by groups if they overlap?
So, I would like to plot points using ggplot separated by groups, but because they overlap the colour by group function doesn't seem so effective visually, I already set the alpha to 0.3.因此,我想使用按组分隔的 ggplot 绘制点,但是因为它们按组功能重叠颜色在视觉上看起来并不那么有效,我已经将 alpha 设置为 0.3。 What else could I do?
我还能做什么?
I am assuming that you have something like the following:我假设您有以下内容:
df <- data.frame(x = c((1:10)-0.05, 1:10, 1:10), y = c(1:10, 1:20), group = paste('Group', 1:10))
df$group <- factor(df$group, levels = unique(df$group))
ggplot(df, aes(x, y, colour = group), alpha=0.3)+
geom_point()
So, as suggested by @Duck you can plot the points in separate plots using facet_wrap
as in the following:因此,正如@Duck 所建议的,您可以使用
facet_wrap
在单独的图中绘制点,如下所示:
df <- data.frame(x = c((1:10)-0.05, 1:10, 1:10), y = c(1:10, 1:20), group = paste('Group', 1:10))
df$group <- factor(df$group, levels = unique(df$group))
ggplot(df, aes(x, y))+
geom_point()+
facet_wrap(~group)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.