Skip to content

Commit dd61716

Browse files
committed
changed aspects_on_axis to show_features in plot.aspect_importance
1 parent 11df8e8 commit dd61716

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ patchwork 1.0.1
66
to change in DALEX 1.2.1)
77
* added parameter to change correlation method in group_variables,
88
cluster_variables, triplot
9-
9+
* deprecated aspects_on_axis argument in plot.aspect_importance (now it’s
10+
show_features) (#14)
1011

1112
# triplot 1.2
1213

R/aspect_importance.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,10 @@ aspect_importance.default <- function(x, data,
234234
#'
235235
#' @param x object of aspect_importance class
236236
#' @param bar_width bar width
237-
#' @param aspects_on_axis if TRUE, labels on axis Y show aspect names, otherwise
237+
#' @param show_features if TRUE, labels on axis Y show aspect names, otherwise
238238
#' they show features names
239+
#' @param aspects_on_axis alias for \code{show_features} held for backwards
240+
#' compatibility
239241
#' @param add_importance if TRUE, plot is annotated with values of aspects
240242
#' importance
241243
#' @param digits_to_round integer indicating the number of decimal places used
@@ -278,6 +280,7 @@ aspect_importance.default <- function(x, data,
278280

279281

280282
plot.aspect_importance <- function(x, ..., bar_width = 10,
283+
show_features = aspects_on_axis,
281284
aspects_on_axis = TRUE,
282285
add_importance = FALSE,
283286
digits_to_round = 2,
@@ -300,7 +303,7 @@ plot.aspect_importance <- function(x, ..., bar_width = 10,
300303

301304
# reformat features list --------------------------------------------------
302305

303-
if (!aspects_on_axis) {
306+
if (!show_features) {
304307
x$features <- sapply(x$features, paste0, collapse = ", ")
305308
}
306309

@@ -318,7 +321,7 @@ plot.aspect_importance <- function(x, ..., bar_width = 10,
318321

319322
# prep plot ---------------------------------------------------------------
320323

321-
if (aspects_on_axis) {
324+
if (show_features) {
322325
p <- ggplot(x, aes(variable_groups, ymin = 0, ymax = importance,
323326
color = a_sign)) +
324327
geom_linerange(size = bar_width) +
@@ -330,12 +333,12 @@ plot.aspect_importance <- function(x, ..., bar_width = 10,
330333
facet_wrap(~label, scales = "free_y", nrow = 1)
331334
}
332335

333-
if (add_importance & aspects_on_axis) {
336+
if (add_importance & show_features) {
334337
p <- p + geom_text(aes(x = variable_groups, y = importance,
335338
label = round(importance, digits_to_round),
336339
hjust = hjust), vjust = 0.5, color = "#371ea3",
337340
size = text_size)
338-
} else if (add_importance & !aspects_on_axis) {
341+
} else if (add_importance & !show_features) {
339342
p <- p + geom_text(aes(x = features, y = importance,
340343
label = round(importance, digits_to_round),
341344
hjust = hjust),

man/plot.aspect_importance.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test_aspect_importance.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ test_that("check plot (facets) for aspects importance",{
164164

165165
expect_is(plot(aspect_importance_apartments1, aspect_importance_apartments2,
166166
aspect_importance_apartments3, add_importance = TRUE,
167-
aspects_on_axis = FALSE, digits_to_round = 0), "gg")
167+
show_features = FALSE, digits_to_round = 0), "gg")
168168
})
169169

170170

vignettes/vignette_aspect_importance_indepth.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ print(Boston_ai_lm_2, show_features = TRUE)
189189
190190
print(Boston_ai_rf_2, show_features = TRUE)
191191
192-
plot(Boston_ai_lm_2, Boston_ai_rf_2, aspects_on_axis = FALSE)
192+
plot(Boston_ai_lm_2, Boston_ai_rf_2, show_features = FALSE)
193193
194194
```
195195

0 commit comments

Comments
 (0)