跟着Nature Communications学作图:R语言ggplot2画天下舆图并用md语法添加文

分享
开发者 2024-9-25 22:33:17 53 0 来自 中国
论文

MiDAS 4: A global catalogue of full-length 16S rRNA gene sequences and taxonomy for studies of bacterial communities in wastewater treatment plants
https://www.nature.com/articles/s41467-022-29438-7
数据链接
https://figshare.com/articles/dataset/Dueholm2021a_data_zip/16566408/1
代码链接
https://github.com/msdueholm/MiDAS4
本日的推文我们重复一下论文中的Figure1a 天下舆图
之前的推文先容过天下舆图添加采样所在
起首是舆图

我这里就不画国家的边界了,原来是想添加每个洲的边界的,但是临时没有找到办法,想到了再来先容吧
library(ggplot2)world<-map_data("world")ggplot() +  geom_polygon(data=world,aes(x=long,y=lat,group=group),               fill="#dedede")+  theme_bw()+  scale_y_continuous(expand = expansion(mult=c(0,0)))+  scale_x_continuous(expand = expansion(add=c(0,0))) -> world.mapworld.map添加采样点
df<-read.csv("figure1df.csv")world.map+  geom_point(data = df,             aes(x=Longitude,                  y=Latitude,                  colour = Process_type2), size=2)+  scale_color_manual(values = c("#3373a5","#97b1c0",                                         "#f8ad63",                                         "#d8191a",                                         "#c4c4c4"))添加文本标签
library(ggtext)                                  dftext<-data.frame(  x=c(-180,-150,-10,100,50,-50),  y=c(40,-50,-50,-50,50,60),  label=c("**North america**<br>3 countries<br>107 cities<br>145WWTPs",          "**South american**<br>2 countries<br>29 cities<br>38 WWTPs",          3,4,5,6))world.map01 +  theme(legend.position = c(0.9,0.7),        legend.background = element_rect(fill="transparent"),        legend.box.background = element_rect(color="gray",                                             fill="transparent"),        legend.key = element_rect(fill="transparent"))+  geom_richtext(data=dftext,                aes(x=x,y=y,label=label),                nudge_x =0,hjust=0,                fill="transparent")
示例数据和代码可以直接到论文中去获取 大概给推文点赞,点击在看,然后留言获取
欢迎大家关注我的公众号
小明的数据分析条记本
小明的数据分析条记本 公众号 紧张分享:1、R语言和python做数据分析和数据可视化的简朴小例子;2、园艺植物干系转录组学、基因组学、群体遗传学文献阅读条记;3、生物信息学入门学习资料及自己的学习条记!
您需要登录后才可以回帖 登录 | 立即注册

Powered by CangBaoKu v1.0 小黑屋藏宝库It社区( 冀ICP备14008649号 )

GMT+8, 2024-10-18 22:34, Processed in 0.168919 second(s), 32 queries.© 2003-2025 cbk Team.

快速回复 返回顶部 返回列表