Skip to content

Commit e79fa56

Browse files
authored
Move vthemes plotting theme (used in visualizer library functions) to global option (#161)
* add plot_theme to global option * Change default ggplot theme from vthemes to default ggplot * Allow user to set default plotting theme in the global options * update test snapshots
1 parent 25ef62e commit e79fa56

26 files changed

+2110
-2522
lines changed

R/visualizer-lib-utils.R

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,19 @@ plot_eval_constructor <- function(eval_results = NULL, eval_names = NULL,
402402
}
403403
}
404404
# add theme
405-
plt <- plt + vthemes::theme_vmodern()
406-
if (!is.null(color_str)) {
407-
discrete <- !is.numeric(plt_df[[color_str]])
408-
plt <- plt +
409-
vthemes::scale_color_vmodern(discrete = discrete) +
410-
vthemes::scale_fill_vmodern(discrete = discrete)
405+
plot_theme <- getOption("simChef.plot_theme", "default")
406+
if (!identical(plot_theme, "default")) {
407+
if (identical(plot_theme, "vthemes")) {
408+
plt <- plt + vthemes::theme_vmodern()
409+
if (!is.null(color_str)) {
410+
discrete <- !is.numeric(plt_df[[color_str]])
411+
plt <- plt +
412+
vthemes::scale_color_vmodern(discrete = discrete) +
413+
vthemes::scale_fill_vmodern(discrete = discrete)
414+
}
415+
} else {
416+
plt <- plt + plot_theme
417+
}
411418
}
412419
# add labels
413420
labels_ls <- purrr::map(

R/zzz.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
op <- options()
66
op.simChef <- list(
7-
simChef.debug = FALSE
7+
simChef.debug = FALSE,
8+
simChef.plot_theme = "default"
89
# TODO: simChef.verbosity
910
)
1011
toset <- !(names(op.simChef) %in% names(op))

tests/testthat/_snaps/visualizer-lib/plot-eval-constructor1.svg

Lines changed: 80 additions & 102 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-eval-constructor2.svg

Lines changed: 98 additions & 121 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-feature-importance1.svg

Lines changed: 58 additions & 67 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-feature-importance2.svg

Lines changed: 58 additions & 67 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-feature-selection-curve-pr1.svg

Lines changed: 46 additions & 57 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-feature-selection-curve-roc1.svg

Lines changed: 46 additions & 57 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-feature-selection-curve-roc2.svg

Lines changed: 55 additions & 49 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-feature-selection-err1.svg

Lines changed: 239 additions & 312 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-pred-curve-pr1.svg

Lines changed: 46 additions & 57 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-pred-curve-roc1.svg

Lines changed: 46 additions & 57 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-pred-curve-roc2.svg

Lines changed: 55 additions & 49 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-pred-err1.svg

Lines changed: 98 additions & 121 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-pred-err2.svg

Lines changed: 84 additions & 106 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-pred-err3.svg

Lines changed: 96 additions & 118 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-pred-err4.svg

Lines changed: 104 additions & 126 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-reject-prob1.svg

Lines changed: 88 additions & 119 deletions
Loading

tests/testthat/_snaps/visualizer-lib/plot-reject-prob2.svg

Lines changed: 55 additions & 49 deletions
Loading

0 commit comments

Comments
 (0)