Skip to content

Commit

Permalink
ordered and re-ran figures
Browse files Browse the repository at this point in the history
  • Loading branch information
cfree14 committed Nov 10, 2021
1 parent 2e51a31 commit ac02cd7
Show file tree
Hide file tree
Showing 93 changed files with 139 additions and 443 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified code/.DS_Store
Binary file not shown.
54 changes: 0 additions & 54 deletions code/ms_figures/Fig1_fisheries_results.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,57 +252,3 @@ g <- gridExtra::grid.arrange(g1, g2, g3, g4, layout_matrix=layout_matrix, height
ggsave(g, filename=file.path(plotdir, "Fig1_fisheries_results.png"),
width=6.5, height=8, units="in", dpi=600)










#
# Plot national results
##############################
#
# # National per capita trends
# cdata_stats <- cdata %>%
# # Classify countries as experiencing increasing/descreasing per capita supply
# select(rcp, scenario, country, iso3, year, npeople, meat_kg_person) %>%
# filter(year %in% c(2020, 2050, 2100)) %>%
# group_by(rcp, scenario, country, iso3) %>%
# mutate(trend=ifelse(meat_kg_person > meat_kg_person[year==2020], "increase", "decrease")) %>%
# ungroup() %>%
# filter(year!=2020) %>%
# # Tally countries experiencing increasing/decreasing per capita supply
# group_by(rcp, scenario, year, trend) %>%
# summarise(ncountries=n(),
# npeople=sum(npeople)) %>%
# ungroup() %>%
# # Reduce to just decreasing counts
# filter(trend=="decrease")
#
# # Plot data
# g3 <- ggplot(cdata_stats, aes(x=year, y=ncountries, fill=rcp)) +
# facet_grid(~scenario) +
# geom_bar(stat="identity", position = "dodge") +
# labs(y="Number of nations\nwith decreased seafood production per capita") +
# theme_bw()
# g3
#
# # Plot data
# g4 <- ggplot(cdata_stats, aes(x=year, y=npeople/1e9, fill=rcp)) +
# facet_grid(~scenario) +
# geom_bar(stat="identity", position = "dodge") +
# labs(y="Billions of people\nwith decreased seafood production per capita") +
# theme_bw()
# g4
#
#
#
#
#
#
#
#

47 changes: 0 additions & 47 deletions code/ms_figures/Fig2_mariculture_results.R
Original file line number Diff line number Diff line change
Expand Up @@ -333,50 +333,3 @@ g
ggsave(g, filename=file.path(plotdir, "Fig2_mariculture_results.png"),
width=6.5, height=3.5, units="in", dpi=600)








# # Read forage fish availability data
# ffdata <- read.csv("data/feed_params/processed/forage_fish_availability.csv", as.is=T)

# # WC/interaction plot
# ############################################
#
# # Format finfish data
# ffdata_use <- ffdata %>%
# # Mark big-picture scenarios
# mutate(scenario=ifelse(mgmt_scenario=="BAU fisheries management" & feed_scenario=="BAU feed use", "Business-as-usual", NA),
# scenario=ifelse(mgmt_scenario=="BAU fisheries management" & feed_scenario=="Reformed feed use", "Fisheries limiting", scenario),
# scenario=ifelse(mgmt_scenario=="Reformed fisheries management" & feed_scenario=="Reformed feed use", "Progressive reforms", scenario)) %>%
# # Reduce
# filter(!is.na(scenario)) %>%
# select(rcp, scenario, year, catch_ff_mt_maq) %>%
# # Factor new scenario
# mutate(scenario=factor(scenario, levels=c("Business-as-usual", "Fisheries limiting", "Progressive reforms")))
#
# # Plot data
# g5 <- ggplot(ffdata_use, aes(x=year, y=catch_ff_mt_maq/1e6, color=rcp, linetype=scenario)) +
# geom_line() +
# # Axis
# lims(y=c(0,NA)) +
# scale_x_continuous(breaks=c(2012, seq(2020, 2100, 10))) +
# # Labels
# labs(x="", y="Catch directed to mariculture\nfeed ingredients (millions of mt)", tag="e") +
# # Legends
# scale_color_manual(name="", values=RColorBrewer::brewer.pal(4, name="RdBu") %>% rev()) +
# scale_linetype_manual(name="", values=c(3,2,1)) +
# # Theme
# theme_bw() + big_plot_theme +
# theme(legend.position="bottom",
# legend.box = "vertical",
# legend.spacing=unit(0.01, 'cm'),
# legend.box.spacing = unit(0.01, 'cm'),
# legend.key.size = unit(0.4, 'cm'),
# legend.margin=unit(0, "cm"))
# g5


7 changes: 0 additions & 7 deletions code/ms_figures/Fig4_national_production.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,3 @@ ggsave(g, filename=file.path(plotdir, "Fig4_national_production.png"),










2 changes: 1 addition & 1 deletion code/ms_figures/FigS10_species_development.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ g <- ggplot(data, mapping=aes(x=fao_mt_yr+0.001, y=reorder(comm_name, fao_mt_yr)
g

# Export plot
ggsave(g, filename=file.path(plotdir, "FigS5_species_development.png"),
ggsave(g, filename=file.path(plotdir, "FigS10_species_development.png"),
width=6.5, height=8.5, units="in", dpi=600)


Expand Down
59 changes: 59 additions & 0 deletions code/ms_figures/FigS11_harvest_length_linf_perc_boxplots.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

# Clear workspace
rm(list = ls())

# Setup
################################################################################

# Packages
library(stringr)
library(readxl)
library(tidyverse)

# Directories
plotdir <- "figures"
datadir <- "data/feed_params/processed"

# Read data
data <- read.csv(file=file.path(datadir, "FAO_harvest_size_as_prop_of_linf_data.csv"), as.is=T)

# Calculate median
stats <- data1 %>%
group_by(type) %>%
summarize(n=n(),
harvest_perc_linf=median(harvest_perc_linf))

# Plot data
################################################################################

# Setup theme
my_theme <- theme(axis.text=element_text(size=8),
axis.title=element_text(size=10),
plot.title=element_text(size=12),
legend.position = "none",
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black"))

# Plot
g <- ggplot(data, aes(x=type, y=harvest_perc_linf, fill=type)) +
geom_boxplot() +
labs(x="", y="Harvest size as a\npercentage of asymptotic length") +
geom_hline(yintercept=100, linetype="dotted") +
geom_text(data=stats, mapping=aes(x=type, y=harvest_perc_linf,
label=paste0(round(harvest_perc_linf), "%")), vjust=-0.5) +
theme_bw() + my_theme
g

# Export
ggsave(g, filename=file.path(plotdir, "FigS11_harvest_sizes_as_linf_perc.png"),
width=4.5, height=4.5, units="in", dpi=600)








4 changes: 2 additions & 2 deletions code/ms_figures/FigS13_S24_fcr_fmfo_trends.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,12 @@ g <- ggplot(fifos_g, aes(x=year, y=fifo)) +
g

# Export plot
ggsave(g, filename=file.path(plotdir, "figure_fifo_projections.png"),
ggsave(g, filename=file.path(plotdir, "FigS24_fifo_trends_projections.png"),
width=6.5, height=4, units="in", dpi=600)

# Export data
fifo_preds <- pred_df1
save(fifos_g, fifo_proj_g, fifo_preds, file=file.path(feeddir, "FigS24_fifo_trends_projections.Rdata"))
save(fifos_g, fifo_proj_g, fifo_preds, file=file.path(feeddir, "fifo_trends_projections.Rdata"))


# Build output table
Expand Down
2 changes: 1 addition & 1 deletion code/ms_figures/FigS15_arag_sat_calc_example.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ g <- grid.arrange(sst_plot, sal_plot, si_plot, po4_plot, alk_plot, dic_plot, ara
layout_matrix=matrix(c(1:6,7,7), byrow=T, ncol=2), heights=c(rep(0.2,3), 0.4))

# Export
ggsave(g, filename=file.path(plotdir, "FigS10_arag_sat_calc_example.png"),
ggsave(g, filename=file.path(plotdir, "FigS15_arag_sat_calc_example.png"),
width=6.5, height=6.5, units="in", dpi=600)


Expand Down
4 changes: 2 additions & 2 deletions code/ms_figures/FigS17_eezs_analyzed.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ g <- ggplot(eezs) +
scale_fill_discrete(name="") +
theme_bw() + my_theme +
theme(legend.position = "bottom")
g
#g

# Plot data (point version)
# g <- ggplot(eezs_pts) +
Expand All @@ -84,7 +84,7 @@ g
# g

# Export plot
ggsave(g, filename=file.path(plotdir, "figure_eezs_evaluated.png"),
ggsave(g, filename=file.path(plotdir, "FigS17_figure_eezs_evaluated.png"),
width=6.5, height=3.75, units="in", dpi=600)


Expand Down
2 changes: 1 addition & 1 deletion code/ms_figures/FigS18_use_constraints.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ g4
g <- gridExtra::grid.arrange(g1,g2,g3,g4, ncol=2)

# Export
ggsave(g, filename=file.path(plotdir, "FigS17_use constraints.png"),
ggsave(g, filename=file.path(plotdir, "FigS18_use constraints.png"),
width=6.5, height=4, units="in", dpi=600)


Expand Down
51 changes: 1 addition & 50 deletions code/ms_figures/FigS1_mariculture_results_sens_analysis..R
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,6 @@ g6 <- ggplot(pdata_use, aes(x=period, y=meat_mt/1e6, fill=rcp)) +
g6




# Merge and export
############################################

Expand All @@ -327,53 +325,6 @@ g <- gridExtra::grid.arrange(g1, g2, g3, g4, g5, g6,
g

# Export figure
ggsave(g, filename=file.path(plotdir, "Fig2_mariculture_results_sens_analysis.png"),
ggsave(g, filename=file.path(plotdir, "FigS1_mariculture_results_sens_analysis.png"),
width=6.5, height=3.5, units="in", dpi=600)








# # Read forage fish availability data
# ffdata <- read.csv("data/feed_params/processed/forage_fish_availability.csv", as.is=T)

# # WC/interaction plot
# ############################################
#
# # Format finfish data
# ffdata_use <- ffdata %>%
# # Mark big-picture scenarios
# mutate(scenario=ifelse(mgmt_scenario=="BAU fisheries management" & feed_scenario=="BAU feed use", "Business-as-usual", NA),
# scenario=ifelse(mgmt_scenario=="BAU fisheries management" & feed_scenario=="Reformed feed use", "Fisheries limiting", scenario),
# scenario=ifelse(mgmt_scenario=="Reformed fisheries management" & feed_scenario=="Reformed feed use", "Progressive reforms", scenario)) %>%
# # Reduce
# filter(!is.na(scenario)) %>%
# select(rcp, scenario, year, catch_ff_mt_maq) %>%
# # Factor new scenario
# mutate(scenario=factor(scenario, levels=c("Business-as-usual", "Fisheries limiting", "Progressive reforms")))
#
# # Plot data
# g5 <- ggplot(ffdata_use, aes(x=year, y=catch_ff_mt_maq/1e6, color=rcp, linetype=scenario)) +
# geom_line() +
# # Axis
# lims(y=c(0,NA)) +
# scale_x_continuous(breaks=c(2012, seq(2020, 2100, 10))) +
# # Labels
# labs(x="", y="Catch directed to mariculture\nfeed ingredients (millions of mt)", tag="e") +
# # Legends
# scale_color_manual(name="", values=RColorBrewer::brewer.pal(4, name="RdBu") %>% rev()) +
# scale_linetype_manual(name="", values=c(3,2,1)) +
# # Theme
# theme_bw() + big_plot_theme +
# theme(legend.position="bottom",
# legend.box = "vertical",
# legend.spacing=unit(0.01, 'cm'),
# legend.box.spacing = unit(0.01, 'cm'),
# legend.key.size = unit(0.4, 'cm'),
# legend.margin=unit(0, "cm"))
# g5


2 changes: 1 addition & 1 deletion code/ms_figures/FigS21_dist_shore_wb_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,6 @@ g2 <- ggplot() +
g <- grid.arrange(g0, g1, g2, nrow=3)

# Export
ggsave(g, filename=file.path(plotdir, "figure_costs_cdist_wages_diesel.png"),
ggsave(g, filename=file.path(plotdir, "FigS21_costs_cdist_wages_diesel.png"),
width=6.5, height=11.25, units="in", dpi=600)

2 changes: 1 addition & 1 deletion code/ms_figures/FigS22_wage_labor_costs.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ g2 <- ggplot() +
g <- grid.arrange(g1, g2, nrow=2)

# Export
ggsave(g, filename=file.path(plotdir, "figure_farm_wage_labor_costs.png"),
ggsave(g, filename=file.path(plotdir, "FigS22_farm_wage_labor_costs.png"),
width=6.5, height=7.5, units="in", dpi=600)

4 changes: 2 additions & 2 deletions code/ms_figures/FigS23_forage_fish_supply.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plotdir <- "figures"
datadir <- "data/feed_params/processed"

# Export data
data_orig <- read.csv(file.path(outdir, "forage_fish_availability.csv"), as.is=T)
data_orig <- read.csv(file.path(datadir, "forage_fish_availability.csv"), as.is=T)

# Reduce
data <- data_orig %>%
Expand Down Expand Up @@ -58,7 +58,7 @@ g <- ggplot(data, aes(x=year, y=catch_ff_mt_maq/1e6, color=rcp, linetype=mgmt_sc
g

# Export plot
ggsave(g, filename=file.path(plotdir, "FigS24_forage_fish_supply.png"),
ggsave(g, filename=file.path(plotdir, "FigS23_forage_fish_supply.png"),
width=6.5, height=3.5, units="in", dpi=600)


Expand Down
2 changes: 1 addition & 1 deletion code/ms_figures/FigS26_bivalve_carrying_capacity.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ g <- ggplot(data, aes(x=log_ctrt, y=log_ctpt, size=cultured_mt_sqkm, color=impac
g

# Export plot
ggsave(g, filename=file.path(plotdir, "FigS19_bivavle_carrying_capacity.png"),
ggsave(g, filename=file.path(plotdir, "FigS26_bivavle_carrying_capacity.png"),
width=6.5, height=4.5, units="in", dpi=600)

2 changes: 1 addition & 1 deletion code/ms_figures/FigS27_bivalve_meow_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ g3 <- ggplot(results, aes(x=biv_mt_sqkm, fill=dev_scenario)) +
g3

# Export plot
ggsave(g2, filename=file.path(plotdir, "Fig26_bivalve_meow_analysis.png"),
ggsave(g2, filename=file.path(plotdir, "FigS27_bivalve_meow_analysis.png"),
width=6.5, height=3.25, units="in", dpi=600)


Expand Down
2 changes: 1 addition & 1 deletion code/ms_figures/FigS2_global_production_sens_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ g <- gridExtra::grid.arrange(g1, g2, g3, nrow=1, widths=c(0.4, 0.3, 0.3))
g

# Export plot
ggsave(g, filename=file.path(plotdir, "FigSX_global_production_sens_analysis.png"),
ggsave(g, filename=file.path(plotdir, "FigS2_global_production_sens_analysis.png"),
width=6.5, height=2.5, units="in", dpi=600)
2 changes: 1 addition & 1 deletion code/ms_figures/FigS3_national_production_sens_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,6 @@ g2
g <- gridExtra::grid.arrange(g1, g2, nrow=2, heights=c(0.48, 0.52))

# Export data
ggsave(g, filename=file.path(plotdir, "Fig4_national_production_sens_analysis.png"),
ggsave(g, filename=file.path(plotdir, "FigS3_national_production_sens_analysis.png"),
width=6.5, height=5, units="in", dpi=600)

Loading

0 comments on commit ac02cd7

Please sign in to comment.