diff --git a/R/plot_spawning_biomass.R b/R/plot_spawning_biomass.R index 7d23612d..37cfe7d9 100644 --- a/R/plot_spawning_biomass.R +++ b/R/plot_spawning_biomass.R @@ -167,15 +167,15 @@ plot_spawning_biomass <- function( ylab = spawning_biomass_label, group = group, # add check in case facet is returned as character(0) - facet = if (length(facet) > 0) facet else NULL, - ... + facet = if (length(facet) > 0) facet else NULL#, + # ... ) # Add reference line # getting data set - an ifelse statement in the fxn wasn't working final <- reference_line( plot = plt, dat = rp_dat, - era = era, + # era = era, label_name = "spawning_biomass", reference = ref_line, relative = relative, @@ -183,25 +183,26 @@ plot_spawning_biomass <- function( ) + theme_noaa() # Plot vertical lines if era is not filtering - if (is.null(era)) { - # Find unique era - eras <- unique(plot_data$era) - if (length(eras) > 1) { - year_vlines <- c() - for (i in 2:length(eras)) { - erax <- plot_data |> - dplyr::filter(era == eras[i]) |> - dplyr::pull(year) |> - min(na.rm = TRUE) - year_vlines <- c(year_vlines, erax) - } - } - final <- final + - ggplot2::geom_vline( - xintercept = year_vlines, - color = "#999999" - ) - } + # Turning this out because I don't think it's relevant + # if (is.null(era)) { + # # Find unique era + # eras <- unique(plot_data$era) + # if (length(eras) > 1) { + # year_vlines <- c() + # for (i in 2:length(eras)) { + # erax <- plot_data |> + # dplyr::filter(era == eras[i]) |> + # dplyr::pull(year) |> + # min(na.rm = TRUE) + # year_vlines <- c(year_vlines, erax) + # } + # } + # final <- final + + # ggplot2::geom_vline( + # xintercept = year_vlines, + # color = "#999999" + # ) + # } ### Make RDA ---- if (make_rda) { diff --git a/R/utils_plot.R b/R/utils_plot.R index bc27dd91..b6a9d198 100644 --- a/R/utils_plot.R +++ b/R/utils_plot.R @@ -500,7 +500,7 @@ cohort_line <- function( reference_line <- function( plot, dat, - era = "time", + # era = "time", label_name, reference, relative = FALSE, @@ -517,9 +517,6 @@ reference_line <- function( ) } - # Rename era arg - era_name <- era - # Add geom for ref line plot + ggplot2::geom_hline( @@ -532,7 +529,7 @@ reference_line <- function( ggplot2::annotate( geom = "text", # TODO: need to change this for general process - x = as.numeric(max(dat$year[dat$era == era_name], na.rm = TRUE)), # - as.numeric(max(dat$year[dat$era == "time"], na.rm = TRUE))/200, + x = as.numeric(max(ggplot2::ggplot_build(plot)@data[[2]][["x"]], na.rm = TRUE)), # - as.numeric(max(dat$year[dat$era == "time"], na.rm = TRUE))/200, y = ref_line_val / ifelse(relative, ref_line_val, scale_amount), label = glue::glue("{label_name}[{reference}]"), # list(bquote(label_name[.(reference)])), parse = TRUE,