Skip to content
Open
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
2 changes: 1 addition & 1 deletion R/plot_biomass_at_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ plot_biomass_at_age <- function(
create_rda(
object = plot,
# get name of function and remove "plot_" from it
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
fig_or_table = "figure",
dat,
unit_label = "mt"
Expand Down
2 changes: 1 addition & 1 deletion R/plot_catch_comp.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ plot_catch_comp <- function(
create_rda(
object = plot,
# get name of function and remove "plot_" from it
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
fig_or_table = "figure",
dat,
unit_label = "mt"
Expand Down
2 changes: 1 addition & 1 deletion R/plot_indices.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ plot_indices <- function(
create_rda(
object = plt,
# get name of function and remove "plot_" from it
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
fig_or_table = "figure",
dat = dat,
dir = figures_dir,
Expand Down
2 changes: 1 addition & 1 deletion R/plot_landings.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ plot_landings <- function(
create_rda(
object = plt,
# get name of function and remove "plot_" from it
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
fig_or_table = "figure",
dat = dat,
dir = figures_dir,
Expand Down
2 changes: 1 addition & 1 deletion R/plot_natural_mortality.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ plot_natural_mortality <- function(
create_rda(
object = final,
# get name of function and remove "plot_" from it
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
fig_or_table = "figure",
dat = dat,
dir = figures_dir
Expand Down
2 changes: 1 addition & 1 deletion R/plot_recruitment.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ plot_recruitment <- function(
create_rda(
object = final,
# get name of function and remove "plot_" from it
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
fig_or_table = "figure",
dat = dat,
dir = figures_dir # ,
Expand Down
2 changes: 1 addition & 1 deletion R/plot_recruitment_deviations.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ plot_recruitment_deviations <- function(
create_rda(
object = final,
# get name of function and remove "plot_" from it
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
fig_or_table = "figure",
dat = selected_dat,
dir = figures_dir,
Expand Down
2 changes: 1 addition & 1 deletion R/plot_stock_recruitment.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ plot_stock_recruitment <- function(
create_rda(
object = final,
# get name of function and remove "plot_" from it
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
topic_label = gsub("plot_", "", as.character(sys.call()[[1]])),
fig_or_table = "figure",
dat = dat,
dir = figures_dir # ,
Expand Down
4 changes: 2 additions & 2 deletions R/table_bnc.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@
# fig_or_table = fig_or_table,
# dir = tables_dir
# )
#
#
# export_rda(
# object = final,
# caps_alttext = caps_alttext,
# figures_tables_dir = tables_dir,
# # get name of function and remove "table_" from it
# topic_label = gsub("table_", "", as.character(sys.call()[[1]])),
# topic_label = gsub("table_", "", as.character(sys.call()[[1]])),
# fig_or_table = fig_or_table
# )
# }
Expand Down
16 changes: 8 additions & 8 deletions R/table_indices.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@
# )


# export_rda(
# object = final,
# caps_alttext = caps_alttext,
# figures_tables_dir = tables_dir,
# # get name of function and remove "table_" from it
# topic_label = gsub("table_", "", as.character(sys.call()[[1]])),
# fig_or_table = fig_or_table
# )
# export_rda(
# object = final,
# caps_alttext = caps_alttext,
# figures_tables_dir = tables_dir,
# # get name of function and remove "table_" from it
# topic_label = gsub("table_", "", as.character(sys.call()[[1]])),
# fig_or_table = fig_or_table
# )
# }
# final
# }
35 changes: 17 additions & 18 deletions R/theme_noaa.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@
#' ) +
#' ggplot2::geom_point() +
#' theme_noaa()
#'\dontrun{
#' ggplot2::theme_set(stockplotr::theme_noaa())
#'}
#' \dontrun{
#' ggplot2::theme_set(stockplotr::theme_noaa())
#' }
theme_noaa <- function(discrete = TRUE,
...) {

if (utils::packageVersion("ggplot2") < "4.0.0") {
rlang::warn(
message = paste0("Your `ggplot2` version is ", utils::packageVersion("ggplot2"), ", which is older than the version required to use `theme_noaa()` (4.0.0). Please update your `ggplot2` package."),
.frequency = "once",
.frequency_id = "ggplot2_version_warning"
)
}

theme <- ggplot2::theme_bw() +
ggplot2::theme(
plot.background = ggplot2::element_rect(fill = "transparent"),
Expand All @@ -40,24 +39,24 @@ theme_noaa <- function(discrete = TRUE,
text = ggplot2::element_text(size = 14),
plot.margin = ggplot2::margin(0.5, 1, 0.5, 0.5, "cm"),
...
)
)

# create main palette
pal <- function(n) viridisLite::mako(n, begin = 0.1, end = 0.85)

if (discrete) {
theme <- theme +
ggplot2::theme(
palette.colour.discrete = pal,
palette.fill.discrete = pal
)
} else {
theme <- theme +
ggplot2::theme(
palette.colour.continuous = pal,
palette.fill.continuous = pal
)
}
palette.colour.discrete = pal,
palette.fill.discrete = pal
)
} else {
theme <- theme +
ggplot2::theme(
palette.colour.continuous = pal,
palette.fill.continuous = pal
)
}

theme
}
8 changes: 4 additions & 4 deletions R/utils_rda.R
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ add_more_key_quants <- function(
# write analogous code for each in this section, and remove placeholders from
# the end of write_captions (once we get clarity about how to extract Btarg,
# ssbtarg, and R0)
#
#TODO: When adding code extracting values for landings and/or indices figures/tables, be aware that both figure/table share the same label ("landings" and "indices"). If there's reason, add in extra conditional to check if value is from a figure or table
#

# TODO: When adding code extracting values for landings and/or indices figures/tables, be aware that both figure/table share the same label ("landings" and "indices"). If there's reason, add in extra conditional to check if value is from a figure or table

## biomass
if (topic_cap_alt$label == "biomass") {
if (is.null(dat)) {
Expand Down
3 changes: 3 additions & 0 deletions man/theme_noaa.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions tests/testthat/test-save_all_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ test_that("save_all_plots works when all figures/tables are plotted", {
sort(fig_base_temp_files)
)

# # expect that the tables are all created with expected names
# tab_base_temp_files <- c(
# # "bnc_table.rda",
# # "indices.abundance_table.rda",
# "landings_table.rda"
# )
# expect_equal(
# list.files(fs::path(getwd(), "tables")),
# tab_base_temp_files
# )
# # expect that the tables are all created with expected names
# tab_base_temp_files <- c(
# # "bnc_table.rda",
# # "indices.abundance_table.rda",
# "landings_table.rda"
# )
# expect_equal(
# list.files(fs::path(getwd(), "tables")),
# tab_base_temp_files
# )

# erase temporary testing files
file.remove(fs::path(getwd(), "captions_alt_text.csv"))
Expand Down