Drawing outlines around multiple geom_point groups with ggplot

回眸只為那壹抹淺笑 提交于 2019-12-03 10:56:06

If you reorder the bottoms and tops of your shapes respectively ascending and descending, you can just use geom_polygon on your original data.frame and skip all the convex hull stuff:

VLarge <- VFinal[which(VFinal$Value > 25000),]
VLarge <- VLarge[order(-VLarge$Variable, VLarge$Group),]
VSmall <- VFinal[which(VFinal$Value <= 25000),]
VSmall <- VSmall[order(VSmall$Variable, VSmall$Group),]
VFinal <- rbind(VSmall, VLarge)
ggplot(VFinal, aes(Variable, Value, colour = Group)) + geom_point() + 
    geom_polygon(aes(fill = Group), alpha = 0.3)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!