diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4120f65e..13ec2675 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,6 +13,7 @@ repos: additional_dependencies: - checkmate - data.table + - mlr3 - ggplot2 - mlr3misc - scales diff --git a/R/BenchmarkResult.R b/R/BenchmarkResult.R index a3cba7b6..0bd771de 100644 --- a/R/BenchmarkResult.R +++ b/R/BenchmarkResult.R @@ -17,6 +17,8 @@ #' * `"prc"`: Precision recall curve. See `"roc"`. #' #' @param object ([mlr3::BenchmarkResult]). +#' @param custom_facet_order (`character()`)\cr +#' Vector specyfing a custom facet order. Only applies for `type = "boxplot"`. #' @template param_type #' @template param_measure #' @param ... (`any`): @@ -46,6 +48,7 @@ autoplot.BenchmarkResult = function(object, # nolint type = "boxplot", measure = NULL, + custom_facet_order = NULL, ...) { assert_string(type) @@ -62,6 +65,10 @@ autoplot.BenchmarkResult = function(object, # nolint switch(type, "boxplot" = { + if (!is.null(custom_facet_order)) { + checkmate::assert_character(custom_facet_order) + tab$task_id = factor(tab$task_id, levels = custom_facet_order, ordered = TRUE) + } ggplot(tab, mapping = aes(x = .data$nr, y = .data[[measure_id]])) + geom_boxplot(...) + labs(x = "") + diff --git a/man/autoplot.BenchmarkResult.Rd b/man/autoplot.BenchmarkResult.Rd index 83358b75..13adbffe 100644 --- a/man/autoplot.BenchmarkResult.Rd +++ b/man/autoplot.BenchmarkResult.Rd @@ -4,7 +4,13 @@ \alias{autoplot.BenchmarkResult} \title{Plot for BenchmarkResult} \usage{ -\method{autoplot}{BenchmarkResult}(object, type = "boxplot", measure = NULL, ...) +\method{autoplot}{BenchmarkResult}( + object, + type = "boxplot", + measure = NULL, + custom_facet_order = NULL, + ... +) } \arguments{ \item{object}{(\link[mlr3:BenchmarkResult]{mlr3::BenchmarkResult}).} @@ -15,6 +21,9 @@ Type of the plot. See description.} \item{measure}{(\link[mlr3:Measure]{mlr3::Measure})\cr Performance measure to use.} +\item{custom_facet_order}{(\code{character()})\cr +Vector specyfing a custom facet order. Only applies for \code{type = "boxplot"}.} + \item{...}{(\code{any}): Additional arguments, passed down to the respective \code{geom} or plotting function.} }