Skip to content

Commit

Permalink
Merge pull request #137 from NOAA-EDAB/dev
Browse files Browse the repository at this point in the history
bring internal review changes to datasets and plots into master
  • Loading branch information
andybeet authored Mar 7, 2024
2 parents 85d7ff3 + 9b1f90a commit a1c77dc
Show file tree
Hide file tree
Showing 34 changed files with 19,418 additions and 18,542 deletions.
2 changes: 1 addition & 1 deletion R/plot_abc_acl.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ plot_abc_acl <- function(shadedRegion = NULL,
ggplot2::ggtitle("ABC or ACL for Managed Species")+
ggplot2::theme(legend.text = ggplot2::element_text(size = 8),
legend.key.height = ggplot2::unit(2, "mm"))+
ggplot2::ylab("ABC or ACL")+
ggplot2::ylab("ABC or ACL, metric tons")+
ggplot2::xlab(ggplot2::element_blank())+
ecodata::theme_ts()+
ggplot2::guides(fill=ggplot2::guide_legend(ncol=1))+
Expand Down
9 changes: 2 additions & 7 deletions R/plot_aggregate_biomass.R
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,8 @@ plot_aggregate_biomass <- function(shadedRegion = NULL,
}


p <- cowplot::plot_grid(p1, p2, p3, p4, nrow=4)


y.grob <- grid::textGrob(expression("Biomass (kg tow"^-1*")"),
gp=grid::gpar( col="black", fontsize=15), rot=90)

p <- gridExtra::grid.arrange(gridExtra::arrangeGrob(p, left = y.grob))
p <- cowplot::plot_grid(p1, p2, p3, p4, nrow=4,scale = 0.9) +
cowplot::draw_label(expression("Biomass (kg tow"^-1*")"), x= 0, y=0.5, vjust= 1.5, angle=90)

#ggplot2::ylab(expression("Biomass (kg tow"^-1*")"))
return(p)
Expand Down
6 changes: 3 additions & 3 deletions R/plot_bennet.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ plot_bennet <- function(shadedRegion = NULL,
ggplot2::facet_grid(EPU~Var, scales = "free")+
ggplot2::scale_colour_grey(name ="Component") +
ggplot2::ggtitle("Bennet Indicator")+
ggplot2::labs(y=paste0("Value $1,000,000 ($", bennet_year, ")")) +
ggplot2::labs(y=paste0("Million USD (", bennet_year, ")")) +

ggplot2::xlab(ggplot2::element_blank())+
#ggplot2::scale_x_continuous(breaks = seq(1965, 2020, by = 10), expand = c(0.01, 0.01)) +
Expand Down Expand Up @@ -117,7 +117,7 @@ plot_bennet <- function(shadedRegion = NULL,
ggplot2::geom_line(data = revchange, ggplot2::aes(x = Time, y = Value, color = "$"))+
ggplot2::scale_colour_grey(name ="Revenue Change") +
ggplot2::ggtitle("Bennet Indicator")+
ggplot2::labs(y=paste0("Value $1,000,000 ($", bennet_year, ")")) +
ggplot2::labs(y=paste0("Million USD (", bennet_year, ")")) +
ggplot2::scale_x_continuous(breaks = seq(1980, 2020, by = 5), expand = c(0.01, 0.01)) +
#::scale_y_continuous(breaks = seq(y.lim[1], y.lim[2], by = 100),
# limits = y.lim, expand = c(0.01, 0.01)) +
Expand Down Expand Up @@ -160,7 +160,7 @@ plot_bennet <- function(shadedRegion = NULL,
ggplot2::geom_line(data = revchange, ggplot2::aes(x = Time, y = Value, color = "$"))+
ggplot2::scale_colour_grey(name ="Revenue Change") +
ggplot2::ggtitle("Bennet Indicator")+
ggplot2::labs(y=paste0("Value $1,000,000 ($", bennet_year, ")")) +
ggplot2::labs(y=paste0("Million USD (", bennet_year, ")")) +
ggplot2::scale_x_continuous(breaks = seq(1980, 2015, by = 10), expand = c(0.01, 0.01)) +
#ggplot2::scale_y_continuous(breaks = seq(y.lim[1], y.lim[2], by = 100),
# limits = y.lim, expand = c(0.01, 0.01)) +
Expand Down
4 changes: 2 additions & 2 deletions R/plot_ch_bay_sal.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ plot_ch_bay_sal <- function(shadedRegion = NULL,
ggplot2::ggplot() +
ggplot2::geom_ribbon(ggplot2::aes(x = Time, ymin = minLTA, ymax = maxLTA), fill = "grey", alpha = 0.5)+

ggplot2::geom_line(ggplot2::aes(x = Time, y = YearLTA, color= "Long Term Average 2010-2020")) +
ggplot2::geom_line(ggplot2::aes(x = Time, y = Year, color = "Daily (Current Year)")) +
ggplot2::geom_line(ggplot2::aes(x = Time, y = YearLTA, color= "Long Term Average 2010-2022")) +
ggplot2::geom_line(ggplot2::aes(x = Time, y = Year, color = "Daily 2023")) +
ggplot2::ylab("Salinity") +
ggplot2::ggtitle("Chesapeake Bay Salinity") +
ggplot2::theme(legend.position = "bottom",
Expand Down
4 changes: 2 additions & 2 deletions R/plot_ch_bay_temp.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ plot_ch_bay_temp <- function(shadedRegion = NULL,
ggplot2::ggplot() +
ggplot2::geom_ribbon(ggplot2::aes(x = Time, ymin = minLTAC, ymax = maxLTAC), fill = "grey", alpha = 0.5)+

ggplot2::geom_line(ggplot2::aes(x = Time, y = YearLTAC, color= "Long Term Average 2010-2020")) +
ggplot2::geom_line(ggplot2::aes(x = Time, y = YearC, color = "Daily 2022")) +
ggplot2::geom_line(ggplot2::aes(x = Time, y = YearLTAC, color= "Long Term Average 2010-2022")) +
ggplot2::geom_line(ggplot2::aes(x = Time, y = YearC, color = "Daily 2023")) +
ggplot2::ylab("Temperature (C)") +
ggplot2::ggtitle("Chesapeake Bay Temperature") +
ggplot2::theme(legend.position = "bottom",
Expand Down
15 changes: 9 additions & 6 deletions R/plot_chl_pp.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ plot_chl_pp <- function(shadedRegion = NULL,
linetype = setup$hline.lty)+
ecodata::theme_facet() +
ggplot2::theme(strip.text=ggplot2::element_text(hjust=0))

p <- "This data set is currently under review"

}

if(plottype == "weekly") {
Expand Down Expand Up @@ -193,12 +196,12 @@ plot_chl_pp <- function(shadedRegion = NULL,
}

# optional code for New England specific (2 panel) formatting
if (report == "NewEngland") {
p <- p +
ggplot2::theme(legend.position = "bottom",
legend.title = ggplot2::element_blank())

}
# if (report == "NewEngland") {
# p <- p +
# ggplot2::theme(legend.position = "bottom",
# legend.title = ggplot2::element_blank())
#
# }

return(p)

Expand Down
13 changes: 8 additions & 5 deletions R/plot_comdat.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ plot_comdat <- function(shadedRegion = NULL,
totdat<- landings_agg |>
dplyr::filter(EPU %in% filterEPUs)

ylabdat <- expression("Landings (10"^3*"metric tons)")
ylabdat <- expression("Landings (10"^3*" metric tons)")
}

if(varName == "revenue") {
Expand Down Expand Up @@ -154,7 +154,8 @@ plot_comdat <- function(shadedRegion = NULL,
"Piscivore JOINT managed species - Revenue",
"Planktivore JOINT managed species - Revenue",
"Benthivore JOINT managed species - Revenue",
"Benthos JOINT managed species - Revenue")) |>
"Benthos JOINT managed species - Revenue"),
Time >= 1982) |>
#rbind(apex) |>
dplyr::filter(stringr::str_detect(Var, paste0("JOINT|", setup$council_abbr))) |>
dplyr::mutate(Status = c("Council Managed")) #Create groups for
Expand All @@ -179,13 +180,15 @@ plot_comdat <- function(shadedRegion = NULL,
"Benthivore Revenue",
"Apex Predator Revenue",
"Benthos Revenue",
"Other Revenue")) |>
"Other Revenue"),
Time >= 1982) |>
dplyr::mutate(grouping = c("Total")) |>
tidyr::separate(Var, into = c("feeding.guild"), sep = " ") |>
dplyr::mutate(Value = Value/1000)

rev_total<- ecodata::comdat |>
dplyr::filter(Var == "Revenue") |>
dplyr::filter(Var == "Revenue",
Time >= 1982) |>
dplyr::mutate(Status = c("Total")) |>
dplyr::group_by(Status, Time, EPU) |>
dplyr::summarise(Total = sum(Value)/1000000) |>
Expand All @@ -210,7 +213,7 @@ plot_comdat <- function(shadedRegion = NULL,
dplyr::filter(Time >1982) |>
dplyr::filter(EPU %in% filterEPUs)

ylabdat <- expression("Revenue (10"^6*"USD)")
ylabdat <- expression("Revenue (10"^6*" USD)")
}

# code for generating plot object p
Expand Down
16 changes: 11 additions & 5 deletions R/plot_engagement.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ plot_engagement <- function(shadedRegion = NULL,
show.legend = FALSE, direction = "both", box.padding = 0.2, size = 3)+
ggplot2::scale_color_manual(values = c("MedHigh to High"="#D95F02",
"Medium"="#7570B3",
"All Other Communities" = "#1B9E77")) +
"All Other Communities" = "#1B9E77"),
labels = c('MedHigh to High' = 'Medium-High to High','Medium' = 'Medium','All Other Communities'='All Other Communities')) +
# ggplot2::scale_color_brewer(palette = c("#F8766D","#00BA38","#619CFF"),#"Dark2", #Change legend labels for clarity
# breaks = eng$EJRating) +

Expand All @@ -79,10 +80,15 @@ plot_engagement <- function(shadedRegion = NULL,
#ecodata::theme_facet()


p <- gridExtra::grid.arrange(eng2, bottom = grid::textGrob("Low <---------------------------------------------------------------------------------------------------------------------------> High",
x = 0.5, y = 1, gp = grid::gpar(fontsize = 7)),
left = grid::textGrob("Low <--------------------------------------------------------------------------------------> High", rot = 90,
x = 1, y = 0.5, gp = grid::gpar(fontsize = 7)))
#p <- gridExtra::grid.arrange(eng2, bottom = grid::textGrob("Low <---------------------------------------------------------------------------------------------------------------------------> High",
# x = 0.5, y = 1, gp = grid::gpar(fontsize = 7)),
# left = grid::textGrob("Low <--------------------------------------------------------------------------------------> High", rot = 90,
# x = 1, y = 0.5, gp = grid::gpar(fontsize = 7)))

p <- cowplot::plot_grid(eng2, nrow=1,scale = 0.9) +
cowplot::draw_label(expression("Low <------------------------------------------------------------------------------------------------------> High"), x= 0.02, y=0.5, vjust= 1.5, angle=90, size = 10) +
cowplot::draw_label(expression("Low <---------------------------------------------------------------------------------------------------------------------------> High"), x= 0.5, y=0.05, vjust= 1.5, angle=0, size = 10)


return(p)

Expand Down
4 changes: 4 additions & 0 deletions R/plot_grayseal.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ plot_grayseal <- function(shadedRegion = NULL,
p <- ecodata::grayseal |>
dplyr::filter(Var %in% c("pbr", "totalest5y", "totalest1y")) |>
ggplot2::ggplot()+
#Highlight last ten years
ggplot2::annotate("rect", fill = setup$shade.fill, alpha = setup$shade.alpha,
xmin = setup$x.shade.min , xmax = setup$x.shade.max,
ymin = -Inf, ymax = Inf) +
ggplot2::geom_line(ggplot2::aes(x = Time, y = Value, linetype = Var, color = Var))+
ggplot2::geom_ribbon(data = ribbon, ggplot2::aes(ymin = total5yLCI, ymax =total5yUCI, x = Time), fill = "blue", alpha = 0.2)+
ggplot2::ggtitle("Gray Seal Bycatch")+
Expand Down
2 changes: 1 addition & 1 deletion R/plot_gsi.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ plot_gsi <- function(shadedRegion = NULL,
# }

if (report == "NewEngland") {
p <- NULL
p <- "This indicator is only present in the `MidAtlantic` report"
}

return(p)
Expand Down
2 changes: 1 addition & 1 deletion R/plot_habitat_diversity.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,5 @@ plot_habitat_diversity <- function(shadedRegion = NULL,

}

attr(plot_habitat_diversity,"varName") <- c("Diversity","Richness")
attr(plot_habitat_diversity,"varName") <- c("Richness") #removed "Diversity", argument for varName per Laurel's request
attr(plot_habitat_diversity,"report") <- c("MidAtlantic","NewEngland")
2 changes: 1 addition & 1 deletion R/plot_habs.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ plot_habs <- function(shadedRegion = NULL,
ecodata::theme_facet()

if(report == "MidAtlantic") {
p <- NULL
p <- "This indicator is only present in the 'NewEngland' report"
}

return(p)
Expand Down
6 changes: 5 additions & 1 deletion R/plot_harborporpoise.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ plot_harborporpoise <- function(shadedRegion = NULL,
p <- ecodata::harborporpoise |>
dplyr::filter(Var %in% c("pbr", "totalest5y", "totalest1y")) |>
ggplot2::ggplot()+
#Highlight last ten years
ggplot2::annotate("rect", fill = setup$shade.fill, alpha = setup$shade.alpha,
xmin = setup$x.shade.min , xmax = setup$x.shade.max,
ymin = -Inf, ymax = Inf) +
ggplot2::geom_line(ggplot2::aes(x = Time, y = Value, linetype = Var, color = Var))+
ggplot2::geom_ribbon(data = ribbon, ggplot2::aes(ymin = total5yLCI, ymax =total5yUCI, x = Time), fill = "blue", alpha = 0.2)+
ggplot2::ggtitle("Harbor Porpoise Bycatch")+
Expand All @@ -50,7 +54,7 @@ plot_harborporpoise <- function(shadedRegion = NULL,
labels = c("PBR", "Annual Estimates", "5yr rolling mean and CI"))+
ggplot2::theme(#legend.position = "none",
legend.title = ggplot2::element_blank(),
legend.position = c(0.75, 0.8),
legend.position = c(0.5, 0.8),
legend.text = ggplot2::element_text(size = 8),
legend.background = ggplot2::element_rect(
colour = "transparent", fill = "transparent"))+
Expand Down
46 changes: 34 additions & 12 deletions R/plot_mab_inshore_survey.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,37 @@ plot_mab_inshore_survey <- function(shadedRegion = NULL,

# optional code to wrangle ecodata object prior to plotting
# e.g., calculate mean, max or other needed values to join below
fix <- ecodata::mab_inshore_survey |>
dplyr::filter(EPU %in% filterEPUs,
grepl("Value",Var)) |>
tidyr::separate(Var,into = c("Var","Trash"),sep ="-") |>
dplyr::select(-Trash) |>
dplyr::mutate(Var = as.factor(Var)) |>
dplyr::group_by(Var) |>
dplyr::mutate(hline = mean(Value))
fix <- ecodata::mab_inshore_survey |>
tidyr::separate(Var, into = c("Var", "Val"), sep = "-") |>
tidyr::pivot_wider(names_from = Val, values_from = Value) |>
dplyr::mutate(Value = as.numeric(Value),
CV = as.numeric(CV)) |>
dplyr::group_by(Var) |>
dplyr::mutate(hline = mean(Value),
SD = Value * CV, #calculate SD from CV
upper = Value + (2*SD),
lower = Value - (2*SD))

fix$Var <- factor(fix$Var,levels = c("Piscivore Spring","Piscivore Fall",
"Benthivore Spring","Benthivore Fall",
"Planktivore Spring","Planktivore Fall",
"Benthos Spring","Benthos Fall"))
fix$Var <- factor(fix$Var,levels = c("Piscivore Spring","Piscivore Fall",
"Benthivore Spring", "Benthivore Fall",
"Planktivore Spring", "Planktivore Fall",
"Benthos Spring", "Benthos Fall"))


# code before adding standard deviation calculation
#fix <- ecodata::mab_inshore_survey |>
# dplyr::filter(EPU %in% filterEPUs,
# grepl("Value",Var)) |>
#tidyr::separate(Var,into = c("Var","Trash"),sep ="-") |>
#dplyr::select(-Trash) |>
#dplyr::mutate(Var = as.factor(Var)) |>
#dplyr::group_by(Var) |>
#dplyr::mutate(hline = mean(Value))

#fix$Var <- factor(fix$Var,levels = c("Piscivore Spring","Piscivore Fall",
#"Benthivore Spring","Benthivore Fall",
#"Planktivore Spring","Planktivore Fall",
#"Benthos Spring","Benthos Fall"))


ymax <- fix |>
Expand Down Expand Up @@ -75,6 +93,10 @@ plot_mab_inshore_survey <- function(shadedRegion = NULL,
linewidth = setup$hline.size,
alpha = setup$hline.alpha,
linetype = setup$hline.lty)+
ggplot2::geom_ribbon(data = fix,
ggplot2::aes(x = Time, ymin = pmax(lower,0), ymax = upper),
alpha = 0.5,
fill = "gray")+
ggplot2::ggtitle("NEAMAP inshore BTS")+
ggplot2::ylab(expression("Biomass (kg tow"^-1*")"))+
ggplot2::xlab(ggplot2::element_blank())+
Expand Down
Loading

0 comments on commit a1c77dc

Please sign in to comment.