Skip to content

Commit

Permalink
Move vthemes plotting theme (used in visualizer library functions) …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
tiffanymtang authored Jul 3, 2023
1 parent 25ef62e commit e79fa56
Show file tree
Hide file tree
Showing 26 changed files with 2,110 additions and 2,522 deletions.
19 changes: 13 additions & 6 deletions R/visualizer-lib-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,19 @@ plot_eval_constructor <- function(eval_results = NULL, eval_names = NULL,
}
}
# add theme
plt <- plt + vthemes::theme_vmodern()
if (!is.null(color_str)) {
discrete <- !is.numeric(plt_df[[color_str]])
plt <- plt +
vthemes::scale_color_vmodern(discrete = discrete) +
vthemes::scale_fill_vmodern(discrete = discrete)
plot_theme <- getOption("simChef.plot_theme", "default")
if (!identical(plot_theme, "default")) {
if (identical(plot_theme, "vthemes")) {
plt <- plt + vthemes::theme_vmodern()
if (!is.null(color_str)) {
discrete <- !is.numeric(plt_df[[color_str]])
plt <- plt +
vthemes::scale_color_vmodern(discrete = discrete) +
vthemes::scale_fill_vmodern(discrete = discrete)
}
} else {
plt <- plt + plot_theme
}
}
# add labels
labels_ls <- purrr::map(
Expand Down
3 changes: 2 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

op <- options()
op.simChef <- list(
simChef.debug = FALSE
simChef.debug = FALSE,
simChef.plot_theme = "default"
# TODO: simChef.verbosity
)
toset <- !(names(op.simChef) %in% names(op))
Expand Down
182 changes: 80 additions & 102 deletions tests/testthat/_snaps/visualizer-lib/plot-eval-constructor1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
219 changes: 98 additions & 121 deletions tests/testthat/_snaps/visualizer-lib/plot-eval-constructor2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 58 additions & 67 deletions tests/testthat/_snaps/visualizer-lib/plot-feature-importance1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 58 additions & 67 deletions tests/testthat/_snaps/visualizer-lib/plot-feature-importance2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
551 changes: 239 additions & 312 deletions tests/testthat/_snaps/visualizer-lib/plot-feature-selection-err1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 46 additions & 57 deletions tests/testthat/_snaps/visualizer-lib/plot-pred-curve-pr1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 46 additions & 57 deletions tests/testthat/_snaps/visualizer-lib/plot-pred-curve-roc1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 55 additions & 49 deletions tests/testthat/_snaps/visualizer-lib/plot-pred-curve-roc2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
219 changes: 98 additions & 121 deletions tests/testthat/_snaps/visualizer-lib/plot-pred-err1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
190 changes: 84 additions & 106 deletions tests/testthat/_snaps/visualizer-lib/plot-pred-err2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
214 changes: 96 additions & 118 deletions tests/testthat/_snaps/visualizer-lib/plot-pred-err3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
230 changes: 104 additions & 126 deletions tests/testthat/_snaps/visualizer-lib/plot-pred-err4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
207 changes: 88 additions & 119 deletions tests/testthat/_snaps/visualizer-lib/plot-reject-prob1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 55 additions & 49 deletions tests/testthat/_snaps/visualizer-lib/plot-reject-prob2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e79fa56

Please sign in to comment.