Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
281 changes: 156 additions & 125 deletions R/plot_abc_acl.R

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions R/plot_aggregate_biomass.R
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,16 @@ plot_aggregate_biomass <- function(shadedRegion = NULL,
color = "#ca0020",na.rm = T)
}


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)
p <- ggpubr::ggarrange(
p1,
p2,
p3,
p4,
nrow = 4,
scale = 0.9)

# 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
11 changes: 11 additions & 0 deletions R/plot_annual_chl_pp.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ plot_annual_chl_pp <- function(shadedRegion = NULL,
ecodata::theme_facet() +
ecodata::theme_title()

if (report == "MidAtlantic") {
p <- p +
ggplot2::coord_cartesian(ylim = c(2e+07, 4e+07), xlim = c(1998, 2023)) +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant hard code years, what happens next year?

ggplot2::ggtitle("MAB Primary Production") +
ggplot2::ylab("Carbon (mt)")
}
else {
p <- p +
ggplot2::theme(axis.title.x = ggplot2::element_blank())
}

return(p)

}
Expand Down
39 changes: 38 additions & 1 deletion R/plot_bennet.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ plot_bennet <- function(shadedRegion = NULL,
ecodata::theme_title()+
ecodata::theme_facet()

if (report == "MidAtlantic") {
p <- p +
ggplot2::theme(legend.position = "bottom") +
ggplot2::facet_wrap(~Var,
nrow = 2)
} else {
p <- p +
ggplot2::theme(legend.position = "bottom",
legend.title = ggplot2::element_blank(),
strip.text.y = ggplot2::element_blank())
}

} else if (varName == "total") {

Expand Down Expand Up @@ -123,9 +134,35 @@ plot_bennet <- function(shadedRegion = NULL,
# limits = y.lim, expand = c(0.01, 0.01)) +
ecodata::theme_ts() +
ggplot2::xlab(ggplot2::element_blank())+
ggplot2::theme(title = ggplot2::element_text(size = 10))+
ecodata::theme_title()

if (report == "MidAtlantic") {
p <- p +
ggplot2::theme(text = ggplot2::element_text(size = 14)) +
ggplot2::theme(
legend.position = "bottom")
}

if (EPU == "GB") {
p <- p +
ggplot2::ggtitle("GB revenue components") +
ggplot2::theme(
legend.position = "none",
legend.title = ggplot2::element_blank()) +
ggplot2::ylab("Million USD (2023)") +
ggplot2::theme(text = ggplot2::element_text(size = 12))
}

if (EPU == "GOM") {
p <- p +
ggplot2::ggtitle("GOM revenue components") +
ggplot2::theme(
legend.position = "bottom",
legend.title = ggplot2::element_blank()) +
ggplot2::ylab("Million USD (2023)") +
ggplot2::theme(text = ggplot2::element_text(size = 12))
}


} else if (varName == "total_guild") {

Expand Down
24 changes: 15 additions & 9 deletions R/plot_benthos_index.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ plot_benthos_index <- function(shadedRegion = NULL,
xmin = setup$x.shade.min , xmax = setup$x.shade.max,
ymin = -Inf, ymax = Inf) +
ggplot2::geom_ribbon(ggplot2::aes(ymin = Lower, ymax = Upper, fill = Season), alpha = 0.5)+
ggplot2::geom_point()+
ggplot2::geom_line()+
ggplot2::geom_point(ggplot2::aes(color = .data$Season)) +
ggplot2::geom_line(ggplot2::aes(color = .data$Season)) +
ggplot2::ggtitle("")+
ggplot2::ylab(paste("Relative",varName,"Biomass"))+
ggplot2::xlab(ggplot2::element_blank())+
Expand All @@ -87,6 +87,11 @@ plot_benthos_index <- function(shadedRegion = NULL,
legend.title = ggplot2::element_blank())

}

if (varName == "Megabenthos") {
p <- p +
ggplot2::theme(legend.position = "none")
}
}

if (plottype == "cog"){
Expand All @@ -111,18 +116,19 @@ plot_benthos_index <- function(shadedRegion = NULL,
xmin = setup$x.shade.min , xmax = setup$x.shade.max,
ymin = -Inf, ymax = Inf) +
ggplot2::geom_ribbon(ggplot2::aes(ymin = Lower, ymax = Upper, fill = Season), alpha = 0.3)+ #
ggplot2::geom_point()+
ggplot2::geom_line()+
ggplot2::ggtitle("")+
ggplot2::ylab(paste(varName," Center of Gravity, km"))+
ggplot2::xlab(ggplot2::element_blank())+
ggplot2::facet_wrap(~Direction, scales = "free_y")+ #Season
ecodata::geom_gls()+
ecodata::geom_lm(n=n)+
ecodata::theme_ts()+
ecodata::theme_facet()+
ecodata::theme_title()

ecodata::theme_title() +
ggplot2::coord_cartesian(xlim = c(1980, 2023)) +
ggplot2::ggtitle("Northeast U.S. Macrobenthos Distribution") +
ggplot2::ylab("Center of Gravity, km") +
ggplot2::geom_point(ggplot2::aes(color = .data$Season)) +
ggplot2::geom_line(ggplot2::aes(color = .data$Season)) +
ggplot2::theme(legend.position = 'bottom') +
ggplot2::facet_grid(cols = ggplot2::vars(Season), rows = ggplot2::vars(Direction), scales = "free_y")
}

return(p)
Expand Down
6 changes: 3 additions & 3 deletions R/plot_cetacean_dist.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ plot_cetacean_dist <- function(shadedRegion = NULL,
#ggplot2::scale_color_manual(values = c("blue", "black", "red"))+
ggplot2::coord_sf(xlim = setup$xlims, ylim = setup$ylims) +
ecodata::theme_map() +
ggplot2::ggtitle("Cetacean Species Distribution") +
ggplot2::xlab("") +
ggplot2::ylab("") +
ggplot2::scale_x_continuous(breaks=c(-76,-72, -68) )+
Expand All @@ -77,8 +76,9 @@ plot_cetacean_dist <- function(shadedRegion = NULL,
strip.text = ggplot2::element_text(hjust=0),
axis.text = ggplot2::element_text(size = 8),
legend.title = ggplot2::element_blank())+#,
#ggplot2::legend.position = c(0.6, 0.15)) +
ggplot2::facet_wrap(~season)
ggplot2::ggtitle("Whale and Dolphin Distribution Shifts") +
ggplot2::facet_wrap(~season, nrow = 1) +
ggplot2::theme(legend.position = "bottom")
# hms_map

# # optional code for New England specific (2 panel) formatting
Expand Down
8 changes: 6 additions & 2 deletions R/plot_chl_pp.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ plot_chl_pp <- function(shadedRegion = NULL,
ggplot2::geom_point() +
ggplot2::geom_line() +
ecodata::geom_lm(n = n) +
ggplot2::scale_x_discrete(name = "", breaks = seq(min(out$Year),max(out$Year),10)) +
ggplot2::scale_x_discrete(name = "", breaks = scales::pretty_breaks(n = 1)) +
ggplot2::facet_wrap(EPU~Month~., ncol = 12) +
ggplot2::ggtitle(paste0("Monthly median ",varabbr)) +
ggplot2::ylab(varunits) +
Expand All @@ -135,9 +135,13 @@ plot_chl_pp <- function(shadedRegion = NULL,
alpha = setup$hline.alpha,
linetype = setup$hline.lty)+
ecodata::theme_facet() +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle=45, hjust = 1),
ggplot2::theme(text = ggplot2::element_text(size = 16),
axis.text.x = ggplot2::element_text(size = 8, angle=45, hjust = 1),
panel.spacing = ggplot2::unit(1, "lines"),
panel.border = ggplot2::element_rect(color = "gray80"),
plot.margin = ggplot2::unit(c(0.1, 0, 0, 0), "cm"))+
ggplot2::facet_grid(rows = ggplot2::vars(EPU), cols = ggplot2::vars(Month)) +
ggplot2::geom_point(color = "white") + ggplot2::geom_line() +
ecodata::theme_title()

}
Expand Down
21 changes: 18 additions & 3 deletions R/plot_comdat.R
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ plot_comdat <- function(shadedRegion = NULL,
dplyr::filter(EPU %in% filterEPUs)

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

}

# code for generating plot object p
Expand Down Expand Up @@ -246,7 +247,6 @@ plot_comdat <- function(shadedRegion = NULL,
ggplot2::scale_color_manual(values = series.col2, aesthetics = "color")+
ggplot2::facet_wrap(~EPU, scales = "free")+
#ggplot2::guides(color = "none") +
ggplot2::ylab(ylabdat) +
ggplot2::xlab(ggplot2::element_blank())+
ggplot2::theme(legend.position = "bottom",
legend.title = ggplot2::element_blank())+
Expand All @@ -258,9 +258,22 @@ plot_comdat <- function(shadedRegion = NULL,
ecodata::theme_ts() +
ggplot2::ggtitle(setup$region)+
ecodata::theme_title() +
ecodata::theme_facet()
ecodata::theme_facet() +
ggplot2::ylab(ylabdat)

if (report == "MidAtlantic") {
p <- p +
ggplot2::theme(strip.text.x = ggplot2::element_blank(),
legend.position = "bottom",
legend.title = ggplot2::element_blank())
} else {
p <- p +
ggplot2::facet_wrap(~EPU,
nrow = 2)
}
}


if(plottype == "guild") {

facet_names <- list("Apex" = expression("Apex"),
Expand Down Expand Up @@ -314,7 +327,9 @@ plot_comdat <- function(shadedRegion = NULL,
legend.position = "bottom",
legend.title = ggplot2::element_blank())+
ggplot2::ggtitle(setup$region)+
ecodata::theme_title()
ecodata::theme_title() +
ggplot2::geom_point(size = 0.05) +
ggplot2::geom_line(size = 0.05)

}

Expand Down
4 changes: 3 additions & 1 deletion R/plot_commercial_div.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ plot_commercial_div <- function(shadedRegion = NULL,
size = setup$hline.size,
alpha = setup$hline.alpha,
linetype = setup$hline.lty) +
ggplot2::theme(plot.margin = ggplot2::unit(c(0.25, 0.5, 0.25, 0.5), "cm")) +
ecodata::theme_ts()+
ecodata::theme_title()
# optional code for New England specific (2 panel) formatting
if (report == "NewEngland") {
p <- p +
ggplot2::theme(legend.position = "bottom",
legend.title = ggplot2::element_blank())
legend.title = ggplot2::element_blank()) +
ggplot2::ylab('Effective Shannon Index')

}

Expand Down
49 changes: 26 additions & 23 deletions R/plot_community_climate_vulnerability.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @param varName Character string. Which variable: ocean acidification sensitivity,
#' temperature sensitivity, stock biomass sensitivity, total sensitivity, total vulnerability
#' ("oaSum","tempSum","stckSum","sensSum","vulnSum")
#' @param plottype Character string. Which plot: proportion of communities (default)
#' @param plottype Character string. Which plot: proportion of communities (default)
#' or regional sensitivity by revenue or landings ("propcomm", "regionrev", "regionland")
#' @param n Numeric scalar. Number of years used (from most recent year) to estimate short term trend . Default = 0 (No trend calculated)
#'
Expand Down Expand Up @@ -51,9 +51,9 @@ plot_community_climate_vulnerability <- function(shadedRegion = NULL,
"Total Climate Sensitivity", "Total Climate Vulnerability")
names(varTitle) <- c("oaSum","tempSum","stckSum",
"sensSum","vulnSum")

if(plottype=="propcomm"){ #proportion of communities

props <- ecodata::community_climate_vulnerability |>
dplyr::filter(!stringr::str_detect(Var, "Regional-")) |>
tidyr::separate(Var, into = c("Town", "StateVar"), sep = ",") |> #using two steps because some towns have - in the name
Expand All @@ -72,18 +72,18 @@ plot_community_climate_vulnerability <- function(shadedRegion = NULL,
dplyr::group_by(Time, EPU, risk) |>
dplyr::mutate(catn = dplyr::n(),
propcat = catn/commn)

propsonly <- props |>
dplyr::select(Time, EPU, risk, propcat) |>
dplyr::distinct()

# code for generating plot object p
# ensure that setup list objects are called as setup$...
# e.g. fill = setup$shade.fill, alpha = setup$shade.alpha,
# xmin = setup$x.shade.min , xmax = setup$x.shade.max
#
p <- ggplot2::ggplot() +

p <- ggplot2::ggplot() +
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) +
Expand All @@ -104,24 +104,25 @@ plot_community_climate_vulnerability <- function(shadedRegion = NULL,
#ggplot2::ggtitle("Mid-Atlantic") +
#ggplot2::theme(legend.position = "blank")
ggplot2::ylab("Proportion communities") +
ggplot2::theme(legend.position = 'bottom')+
ecodata::geom_lm(n=n) +
ecodata::theme_ts()+
ecodata::theme_facet()+
ecodata::theme_title()


return(p)

}else{ #regional plots

if(plottype == "regionrev"){
units <- "value"
type <- "Revenue"
}else{
units <- "pounds"
type <- "Landings"
}

regional <- ecodata::community_climate_vulnerability |>
dplyr::filter(stringr::str_detect(Var, "Regional-")) |>
dplyr::mutate(Varin = stringr::str_extract(Var, '\\b\\w+$'), #keep everything before -
Expand All @@ -130,7 +131,7 @@ plot_community_climate_vulnerability <- function(shadedRegion = NULL,
dplyr::filter(Var %in% varName,
EPU %in% filterEPUs,
Units %in% units)

p <- ggplot2::ggplot() +
#Highlight last ten years
ggplot2::annotate("rect", fill = setup$shade.fill, alpha = setup$shade.alpha,
Expand All @@ -141,7 +142,7 @@ plot_community_climate_vulnerability <- function(shadedRegion = NULL,
alpha = .3) +
ggplot2::scale_fill_manual(values=risk,
breaks=c('Low', 'Moderate', 'High', 'Very High'),
name=varTitle[varName]) +
name=varTitle[varName]) +
# ecodata::geom_gls(data = regional, ggplot2::aes(x = Time, y = Value,
# group = Var),
# alpha = setup$trend.alpha, size = setup$trend.size) +
Expand All @@ -155,19 +156,21 @@ plot_community_climate_vulnerability <- function(shadedRegion = NULL,
ggplot2::theme_bw() +
#ggplot2::ggtitle("Mid-Atlantic") +
#ggplot2::theme(legend.position = "blank")
ggplot2::ylab(paste("Regional", type, varTitle[varName])) +
ggplot2::ylab(paste("Total Climate Vulnerability \n Regional", type)) +
ecodata::theme_ts()+
ecodata::theme_facet()+
ecodata::theme_title()


ecodata::theme_title()+
# ggplot2::ylab("Total Climate Vulnerability \n (Regional Landings)") +
ggplot2::theme(legend.position = 'bottom')


return(p)



}


}

attr(plot_community_climate_vulnerability,"report") <- c("MidAtlantic","NewEngland")
Expand Down
Loading
Loading