ggplot散点图数据上的凸包

问题描述

我一直在努力了解如何添加凸包。

如何基于“ Continent”参数向我的ggplot散点图添加凸包。我想在x轴上绘制“ Pop_Density”,在Y轴上绘制“ Pop_Total”,并使用“死亡”来确定点/点的大小。然后,我想覆盖“大陆”参数的凸包,该参数应将“ Country.Name”中列出的所有国家/地区置于基于“大陆”的凸包中

我现在有以下内容:

p1 <- ggplot(df_data,aes(x = Pop_Density,y = Pop_total,color = region))+
  geom_point(aes(size=Deaths))+ 
  scale_x_log10()+
  scale_y_log10()+
  geom_text(aes(label=Country.Name),size=2,vjust = 0.2,hjust = -0.2,)+
  theme_linedraw()+
  scale_color_manual(values = cbp1)+
p1

我的数据如下:

                      Country.Name        Pop_Density        Pop_total Deaths                Continent
1                      Afghanistan           56.937760        37172386   1497                     Asia
2                           Angola          24.713052         30809762    248                   Africa
3                          Albania         104.612263          2866376    454                   Europe
4                          Andorra         163.842553            77006     62                   Europe
5             United Arab Emirates         135.609110          9630959    466                     Asia
6                        Argentina          16.258510         44494502  26716                 Americas

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...