Skip to content

Commit

Permalink
update legends
Browse files Browse the repository at this point in the history
  • Loading branch information
kmbordin committed Jun 24, 2024
1 parent bcd4023 commit a4852ee
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 25 deletions.
30 changes: 24 additions & 6 deletions R/2.functional_diversity_metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -236,21 +236,30 @@ ggplot(aes(x = Region, y= `Frequency (%)` , fill= Relationship))+
geom_bar(stat= "identity") + geom_text(aes(label=n), vjust=-0.2, hjust=0.5, position=position_stack(vjust=0), colour="black", size=10)+themes+scale_x_discrete(limits=rev)+
scale_fill_manual(values = c("#AA4499","#888888","#44AA99"),guide = guide_legend(
direction = "horizontal", title.position = "top",title.hjust = 0.5))+
labs(x = "", y = "Frequency (%)", title = "Relationship between functional diversity and productivity \n across different regions")
labs(x = "", y = "Frequency (%)", title = "Relationship between functional diversity and productivity \n across different regions")+
theme(legend.title = element_text(size=16), #change legend title font size
legend.text = element_text(size=16),
axis.text=element_text(size=16))

p2 = region_prod %>%
ggplot(aes(x = Region, y= `Frequency (%)` , fill= Relationship))+
geom_bar(stat= "identity") + geom_text(aes(label=n), vjust=-0.2, hjust=0.5, position=position_stack(vjust=0), colour="black", size=10)+themes+scale_x_discrete(limits=rev)+
scale_fill_manual(values = c("#AA4499","#888888","#44AA99"),guide = guide_legend(
direction = "horizontal", title.position = "top",title.hjust = 0.5))+
labs(x = "", y = "Frequency (%)", title = "Relationship between functional diversity and productivity \n across different regions (rate only)")
labs(x = "", y = "Frequency (%)", title = "Relationship between functional diversity and productivity \n across different regions (rate only)") +
theme(legend.title = element_text(size=16), #change legend title font size
legend.text = element_text(size=16),
axis.text=element_text(size=16))

p3 = region_stock %>%
ggplot(aes(x = Region, y= `Frequency (%)` , fill= Relationship))+
geom_bar(stat= "identity") + geom_text(aes(label=n), vjust=-0.2, hjust=0.5, position=position_stack(vjust=0), colour="black", size=10)+themes+scale_x_discrete(limits=rev)+
scale_fill_manual(values = c("#AA4499","#888888","#44AA99"),guide = guide_legend(
direction = "horizontal", title.position = "top",title.hjust = 0.5))+
labs(x = "", y = "Frequency (%)", title = "Relationship between functional diversity and productivity \n across different regions (stock only)")
labs(x = "", y = "Frequency (%)", title = "Relationship between functional diversity and productivity \n across different regions (stock only)")+
theme(legend.title = element_text(size=16), #change legend title font size
legend.text = element_text(size=16),
axis.text=element_text(size=16))

#p1 = total
#p2 = temporal
Expand All @@ -267,19 +276,28 @@ p1 = ecosys_all %>%
geom_bar(stat= "identity") + geom_text(aes(label=n), vjust=-0.2, hjust=0.5, position=position_stack(vjust=0), colour="black", size=10)+themes+scale_x_discrete(limits=rev)+
scale_fill_manual(values = c("#AA4499","#888888","#44AA99"),guide = guide_legend(
direction = "horizontal", title.position = "top",title.hjust = 0.5))+
labs(x = "", y = "Frequency (%)", title = "Relationship between functional diversity and productivity \n across different ecosystems")
labs(x = "", y = "Frequency (%)", title = "Relationship between functional diversity and productivity \n across different ecosystems")+
theme(legend.title = element_text(size=16), #change legend title font size
legend.text = element_text(size=16),
axis.text=element_text(size=16))
p2 = ecosys_prod %>%
ggplot(aes(x = Ecosystem, y= `Frequency (%)` , fill= Relationship))+
geom_bar(stat= "identity") + geom_text(aes(label=n), vjust=-0.2, hjust=0.5, position=position_stack(vjust=0), colour="black", size=10)+themes+scale_x_discrete(limits=rev)+
scale_fill_manual(values = c("#AA4499","#888888","#44AA99"),guide = guide_legend(
direction = "horizontal", title.position = "top",title.hjust = 0.5))+
labs(x = "", y = "Frequency (%)", title = "Relationship between functional diversity and productivity \n across different ecosystems (rate only)")
labs(x = "", y = "Frequency (%)", title = "Relationship between functional diversity and productivity \n across different ecosystems (rate only)") +
theme(legend.title = element_text(size=16), #change legend title font size
legend.text = element_text(size=16),
axis.text=element_text(size=16))
p3 = ecosys_stock %>%
ggplot(aes(x = Ecosystem, y= `Frequency (%)` , fill= Relationship))+
geom_bar(stat= "identity") + geom_text(aes(label=n), vjust=-0.2, hjust=0.5, position=position_stack(vjust=0), colour="black", size=10)+themes+scale_x_discrete(limits=rev)+
scale_fill_manual(values = c("#AA4499","#888888","#44AA99"),guide = guide_legend(
direction = "horizontal", title.position = "top",title.hjust = 0.5))+
labs(x = "", y = "Frequency (%)", title = "Relationship between functional diversity and productivity \n across different ecosystems (stock only)")
labs(x = "", y = "Frequency (%)", title = "Relationship between functional diversity and productivity \n across different ecosystems (stock only)")+
theme(legend.title = element_text(size=16), #change legend title font size
legend.text = element_text(size=16),
axis.text=element_text(size=16))
#p1 = total
#p2 = temporal
#p3 = stock
Expand Down
65 changes: 50 additions & 15 deletions R/3.mass_ratio_metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,46 +260,63 @@ ecosystem <- bind_rows(grass,fores) %>%
mutate(frequencia = replace(frequencia, frequencia == "44" , "45"))%>%
mutate(frequencia = replace(frequencia, frequencia == "62" , "63"))%>%
mutate(frequencia = replace(frequencia, frequencia == "23" , "22"))%>%
mutate(frequencia = as.numeric(frequencia))

mutate(frequencia = as.numeric(frequencia)) %>%
mutate(ecosystem = replace(ecosystem, ecosystem == "Forest" , "F")) %>%
mutate(ecosystem = replace(ecosystem, ecosystem == "Grassland" , "G"))%>%
mutate(Variables = replace(Variables, Variables == "Root quantity" , "Root"))
ecosystem_metric_prod <- bind_rows(grass_prod,fores_prod) %>%
group_by(Variables, ecosystem,metric) %>%
mutate(frequencia = round((`Number of papers`/sum(`Number of papers`) * 100), digits = 0)) %>%
rename(Relationship = Valores)
rename(Relationship = Valores)%>%
mutate(ecosystem = replace(ecosystem, ecosystem == "Forest" , "F")) %>%
mutate(ecosystem = replace(ecosystem, ecosystem == "Grassland" , "G")) %>%
mutate(Variables = replace(Variables, Variables == "Root quantity" , "Root"))

ecosystem_metric_stock <- bind_rows(grass_stock,fores_stock) %>%
group_by(Variables, ecosystem,metric) %>%
mutate(frequencia = round((`Number of papers`/sum(`Number of papers`) * 100), digits = 0)) %>%
rename(Relationship = Valores) %>%
mutate(frequencia = replace(frequencia, frequencia == "38" , "37.5"))%>%
mutate(frequencia = as.numeric(frequencia))
mutate(frequencia = as.numeric(frequencia))%>%
mutate(ecosystem = replace(ecosystem, ecosystem == "Forest" , "F")) %>%
mutate(ecosystem = replace(ecosystem, ecosystem == "Grassland" , "G"))%>%
mutate(Variables = replace(Variables, Variables == "Root quantity" , "Root"))

p1 <- ecosystem %>%
ggplot(aes(x=ecosystem, y=frequencia, fill=Relationship))+geom_bar(stat= "identity") +
labs(x = "", y = "Frequency of papers (%)", title = "Relationship between functional dominance \nand productivity") +
scale_fill_manual(values = c("#AA4499","#888888","#44AA99"),guide = guide_legend(
direction = "horizontal",title.position = "top",title.hjust = 0.5))+
facet_grid(facets = ~(Variables), scales="free") +
geom_text(aes(label=`Number of papers`), vjust=-0.5, hjust=0.5, position=position_stack(vjust=0), colour="black", size=8) + my_theme
geom_text(aes(label=`Number of papers`), vjust=-0.5, hjust=0.5, position=position_stack(vjust=0), colour="black", size=8) + my_theme+
theme(legend.title = element_text(size=16), #change legend title font size
legend.text = element_text(size=16),
axis.text=element_text(size=16))

p2 <- ecosystem_metric_prod %>%
ggplot(aes(x=ecosystem, y=frequencia, fill=Relationship))+geom_bar(stat= "identity") +
labs(x = "", y = "Frequency of papers (%)", title = "Relationship between functional dominance \nand productivity (rate only)") +
scale_fill_manual(values = c("#AA4499","#888888","#44AA99"),guide = guide_legend(
direction = "horizontal",title.position = "top",title.hjust = 0.5))+
facet_grid(facets = ~(Variables), scales="free") +
geom_text(aes(label=`Number of papers`), vjust=-0.5, hjust=0.5, position=position_stack(vjust=0), colour="black", size=8) + my_theme
geom_text(aes(label=`Number of papers`), vjust=-0.5, hjust=0.5, position=position_stack(vjust=0), colour="black", size=8) + my_theme+
theme(legend.title = element_text(size=16), #change legend title font size
legend.text = element_text(size=16),
axis.text=element_text(size=16))

p3 <- ecosystem_metric_stock %>%
ggplot(aes(x=ecosystem, y=frequencia, fill=Relationship))+geom_bar(stat= "identity") +
labs(x = "", y = "Frequency of papers (%)", title = "Relationship between functional dominance \nand productivity (stock only)") +
scale_fill_manual(values = c("#AA4499","#888888","#44AA99"),guide = guide_legend(
direction = "horizontal",title.position = "top",title.hjust = 0.5))+
facet_grid(facets = ~(Variables), scales="free") +
geom_text(aes(label=`Number of papers`), vjust=-0.5, hjust=0.5, position=position_stack(vjust=0), colour="black", size=8) + my_theme
geom_text(aes(label=`Number of papers`), vjust=-0.5, hjust=0.5, position=position_stack(vjust=0), colour="black", size=8) + my_theme+
theme(legend.title = element_text(size=16), #change legend title font size
legend.text = element_text(size=16),
axis.text=element_text(size=16))

plots = (p1|(p2/p3)) +plot_annotation(tag_levels = c("A"))+ plot_layout(widths = c(1, 1))
# png('results/CWM_estoque_temporal_ecosystem.png', units="in", width=35, height=12, res=300)
# png('results/CWM_estoque_temporal_ecosystem.png', units="in", width=12, height=10, res=300)
# plots
# dev.off()

Expand All @@ -313,48 +330,66 @@ regiao <- bind_rows(temp,trop)%>%
mutate(frequencia = replace(frequencia, frequencia == "12" , "13"))%>%
mutate(frequencia = replace(frequencia, frequencia == "35" , "35.5"))%>%
mutate(frequencia = replace(frequencia, frequencia == "27" , "27.5"))%>%
mutate(frequencia = as.numeric(frequencia))
mutate(frequencia = as.numeric(frequencia))%>%
mutate(regiao = replace(regiao, regiao == "Temperate" , "Te")) %>%
mutate(regiao = replace(regiao, regiao == "Tropical" , "Tr")) %>%
mutate(Variables = replace(Variables, Variables == "Root quantity" , "Root"))

regiao_metric_prod <- bind_rows(temp_prod, trop_prod) %>%
group_by(Variables, regiao, metric) %>%
mutate(frequencia = round((`Number of papers`/sum(`Number of papers`) * 100), digits = 0)) %>%
rename(Relationship = Valores)%>%
mutate(frequencia = replace(frequencia, frequencia == "33" , "33.3"))%>%
mutate(frequencia = as.numeric(frequencia))
mutate(frequencia = as.numeric(frequencia))%>%
mutate(regiao = replace(regiao, regiao == "Temperate" , "Te")) %>%
mutate(regiao = replace(regiao, regiao == "Tropical" , "Tr")) %>%
mutate(Variables = replace(Variables, Variables == "Root quantity" , "Root"))

regiao_metric_stock <- bind_rows(temp_stock, trop_stock) %>%
group_by(Variables, regiao, metric) %>%
mutate(frequencia = round((`Number of papers`/sum(`Number of papers`) * 100), digits = 0)) %>%
rename(Relationship = Valores)%>%
mutate(frequencia = replace(frequencia, frequencia == "67" , "66"))%>%
mutate(frequencia = as.numeric(frequencia))
mutate(frequencia = as.numeric(frequencia))%>%
mutate(regiao = replace(regiao, regiao == "Temperate" , "Te")) %>%
mutate(regiao = replace(regiao, regiao == "Tropical" , "Tr")) %>%
mutate(Variables = replace(Variables, Variables == "Root quantity" , "Root"))

p1 <- regiao %>%
ggplot(aes(x=regiao, y=frequencia, fill=Relationship))+geom_bar(stat= "identity") +
labs(x = "", y = "Frequency of papers (%)", title = "Relationship between functional dominance \nand productivity") +
scale_fill_manual(values = c("#AA4499","#888888","#44AA99"),guide = guide_legend(
direction = "horizontal",title.position = "top",title.hjust = 0.5))+
facet_grid(facets = ~(Variables), scales="free") +
geom_text(aes(label=`Number of papers`), vjust=-0.5, hjust=0.5, position=position_stack(vjust=0), colour="black", size=8) + my_theme
geom_text(aes(label=`Number of papers`), vjust=-0.5, hjust=0.5, position=position_stack(vjust=0), colour="black", size=8) + my_theme+
theme(legend.title = element_text(size=16), #change legend title font size
legend.text = element_text(size=16),
axis.text=element_text(size=16))

p2 <- regiao_metric_prod %>%
ggplot(aes(x=regiao, y=frequencia, fill=Relationship))+geom_bar(stat= "identity") +
labs(x = "", y = "Frequency of papers (%)", title = "Relationship between functional dominance \nand productivity (rate only)") +
scale_fill_manual(values = c("#AA4499","#888888","#44AA99"),guide = guide_legend(
direction = "horizontal",title.position = "top",title.hjust = 0.5))+
facet_grid(facets = ~(Variables), scales="free") +
geom_text(aes(label=`Number of papers`), vjust=-0.5, hjust=0.5, position=position_stack(vjust=0), colour="black", size=8) + my_theme
geom_text(aes(label=`Number of papers`), vjust=-0.5, hjust=0.5, position=position_stack(vjust=0), colour="black", size=8) + my_theme+
theme(legend.title = element_text(size=16), #change legend title font size
legend.text = element_text(size=16),
axis.text=element_text(size=16))

p3 <- regiao_metric_stock %>%
ggplot(aes(x=regiao, y=frequencia, fill=Relationship))+geom_bar(stat= "identity") +
labs(x = "", y = "Frequency of papers (%)", title = "Relationship between functional dominance \nand productivity (stock only)") +
scale_fill_manual(values = c("#AA4499","#888888","#44AA99"),guide = guide_legend(
direction = "horizontal",title.position = "top",title.hjust = 0.5))+
facet_grid(facets = ~(Variables), scales="free") +
geom_text(aes(label=`Number of papers`), vjust=-0.5, hjust=0.5, position=position_stack(vjust=0), colour="black", size=8) + my_theme
geom_text(aes(label=`Number of papers`), vjust=-0.5, hjust=0.5, position=position_stack(vjust=0), colour="black", size=8) + my_theme+
theme(legend.title = element_text(size=16), #change legend title font size
legend.text = element_text(size=16),
axis.text=element_text(size=16))

plots = (p1|(p2/p3)) +plot_annotation(tag_levels = c("A"))+ plot_layout(widths = c(1, 1))
# png('results/CWM_estoque_temporal_regiao.png', units="in", width=35, height=12, res=300)
# png('results/CWM_estoque_temporal_regiao.png', units="in", width=12, height=10, res=300)
# plots
# dev.off()

Expand Down
2 changes: 1 addition & 1 deletion R/desktop.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[.ShellClassInfo]
IconResource=C:\Program Files\Google\Drive File Stream\89.0.2.0\GoogleDriveFS.exe,25
IconResource=C:\Program Files\Google\Drive File Stream\92.0.0.0\GoogleDriveFS.exe,25
2 changes: 1 addition & 1 deletion desktop.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[.ShellClassInfo]
IconResource=C:\Program Files\Google\Drive File Stream\89.0.2.0\GoogleDriveFS.exe,25
IconResource=C:\Program Files\Google\Drive File Stream\92.0.0.0\GoogleDriveFS.exe,25
2 changes: 1 addition & 1 deletion processed_data/desktop.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[.ShellClassInfo]
IconResource=C:\Program Files\Google\Drive File Stream\89.0.2.0\GoogleDriveFS.exe,25
IconResource=C:\Program Files\Google\Drive File Stream\92.0.0.0\GoogleDriveFS.exe,25
Binary file modified results/CWM_estoque_temporal_ecosystem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified results/CWM_estoque_temporal_regiao.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified results/FDonprod_ecosys.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified results/FDonprod_temptrop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion results/desktop.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[.ShellClassInfo]
IconResource=C:\Program Files\Google\Drive File Stream\89.0.2.0\GoogleDriveFS.exe,25
IconResource=C:\Program Files\Google\Drive File Stream\92.0.0.0\GoogleDriveFS.exe,25

0 comments on commit a4852ee

Please sign in to comment.