歡迎關注R語言數(shù)據(jù)分析指南
本節(jié)來復現(xiàn)nature communications上一篇文章中地圖的繪制方法,下面來進行復現(xiàn)過程,由于未找到作者提供的數(shù)據(jù)信息,小編自己構建了繪圖文件因此結果與原圖有出入僅供參考。整張圖均使用R代碼進行繪制
Land-use diversity predicts regional bird taxonomic and functional richness worldwide

論文原圖

復現(xiàn)圖
加載R包
# install.packages("rnaturalearthdata")
# install.packages("tidygeocoder")
library(tidygeocoder)
library(tidyverse)
library(sf)
library(camcorder)
library(scico)
library(rnaturalearth)
library(terra)
library(tidyterra)
library(geodata)
library(cowplot)
library(ggsci)
繪制點圖
df1 <- read_tsv("data.xls") %>% filter(type=="Taxonomic richness") %>%
select(5:9) %>%
group_by(REALM) %>%
slice_head(n=1)
df1$REALM <- factor(df$REALM,levels = c("Nearctic","Palearctic","Indomalayan","Neotropic","Afrotropic","Australasia"))
plot1 <- df1 %>% ggplot(aes(y = fct_rev(REALM))) +
theme_bw()+
geom_errorbarh(aes(xmin=Lower_ci,xmax=Upper_ci),height=0.1) +
geom_point(aes(x=visregFit,color=REALM),fill="black",size=3,show.legend = F) +
labs(x="Taxonomic richness",y=NULL)+
scale_color_npg()+
theme(axis.ticks.y= element_blank(),
axis.title.y= element_blank(),
axis.title.x = element_text(color="black",size=8,face="bold"),
axis.text.y=element_text(color="black",size=8,face="bold"),
axis.text.x=element_text(color="black",size=8,face="bold"))
df2 <- read_tsv("data.xls") %>%
filter(type=="Functional richness") %>%
select(5:9) %>%
group_by(REALM) %>%
slice_head(n=1)
df2$REALM <- factor(df$REALM,levels = c("Nearctic","Palearctic","Indomalayan","Neotropic","Afrotropic","Australasia"))
plot2 <- df2 %>% ggplot(aes(y = fct_rev(REALM))) +
theme_bw()+
geom_errorbarh(aes(xmin=Lower_ci,xmax=Upper_ci),height=0.1) +
geom_point(aes(x=visregFit,color=REALM),fill="black",size=3,show.legend = F) +
labs(x="Functional richness",y=NULL)+
scale_color_npg()+
theme(axis.ticks.y= element_blank(),
axis.title.y= element_blank(),
axis.title.x = element_text(color="black",size=8,face="bold"),
axis.text.y=element_text(color="black",size=8,face="bold"),
axis.text.x=element_text(color="black",size=8,face="bold"))
好了本節(jié)介紹到此結束,非常簡單的一個案例喜歡的觀眾老爺歡迎分享轉發(fā),更多精彩案例歡迎關注我的公粽號R語言數(shù)據(jù)分析指南