Skip to content

Commit

Permalink
More compact color bar logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mayer79 committed Sep 8, 2024
1 parent ea85499 commit 564c986
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 9 deletions.
14 changes: 10 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# shapviz 0.9.5
# shapviz 0.10.0

### User-visible changes
### Visible changes in plots

- `sv_dependence()`: The color bar title has been moved from top (horizontal) to left (vertical), and the color bar is less wide (and slightly less high). Furthermore, spacings around color bar have been reduced.
- `sv_dependence2D(): The color bar is less wide (and slightly less high).
- `sv_waterfall()` and `sv_force()`: The x label has been changed from "SHAP value" to "Prediction".

### Documentation

- Add vignette for Tidymodels.
- Update "basic_use" vignette.
- Update README.
- Update of "basic_use" vignette.
- Update of README.

### Other changes

- Bumped minimal {ggplot2} version from 3.4 to 3.5

# shapviz 0.9.4

Expand Down
9 changes: 8 additions & 1 deletion R/sv_dependence.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,14 @@ sv_dependence.shapviz <- function(object, v, color_var = "auto", color = "#3b528
ggplot2::geom_jitter(width = jitter_width, height = 0, ...) +
ggplot2::ylab(y_lab) +
do.call(vir, viridis_args) +
ggplot2::theme(legend.box.spacing = grid::unit(0, "pt"))
ggplot2::theme(
legend.box.spacing = grid::unit(0, "pt"),
legend.margin = ggplot2::margin(r = 0.1, unit = "lines"),
legend.key.width = grid::unit(0.5, "lines"),
legend.key.height = grid::unit(1, "lines"),
legend.title.position = "left",
legend.title = ggplot2::element_text(angle = 90, hjust = 0.5, vjust = 0)
)
}

#' @describeIn sv_dependence
Expand Down
6 changes: 5 additions & 1 deletion R/sv_dependence2D.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ sv_dependence2D.shapviz <- function(object, x, y,
ggplot2::ggplot(dat, ggplot2::aes(x = .data[[x]], y = .data[[y]], color = SHAP)) +
ggplot2::geom_jitter(width = jitter_width, height = jitter_height, ...) +
do.call(vir, viridis_args) +
ggplot2::theme(legend.box.spacing = grid::unit(0, "pt"))
ggplot2::theme(
legend.box.spacing = grid::unit(0, "pt"),
legend.key.width = grid::unit(0.5, "lines"),
legend.key.height = grid::unit(1, "lines")
)
}

#' @describeIn sv_dependence2D
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ sv_dependence(shp, v = x) # patchwork

<img src="man/figures/README-bee.png" alt="beeswarm" width="50%"/>

<img src="man/figures/README-dep.png" alt="scatter" width="70%"/>
<img src="man/figures/README-dep.png" alt="scatter" width="90%"/>


Decompositions of individual predictions can be visualized as waterfall or force plot:
Expand Down
Binary file modified man/figures/README-dep.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packaging.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use_package("stats", "Imports")
use_package("utils", "Imports")
use_package("rlang", "Imports", min_version = "0.3.0")
use_package("grid", "Imports")
use_package("ggplot2", "Imports", min_version = "3.4.0")
use_package("ggplot2", "Imports", min_version = "3.5.0")
use_package("gggenes", "Imports")
use_package("ggfittext", "Imports", min_version = "0.8.0")
use_package("ggrepel", "Imports")
Expand Down
2 changes: 1 addition & 1 deletion vignettes/basic_use.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ shp <- shapviz(fit, X_pred = data.matrix(dia_2000), X = dia_2000)
sv_importance(shp, show_numbers = TRUE)
sv_importance(shp, kind = "beeswarm") # kind = "both" combines bar and bee
```
```{r, fig.width=8.5, fig.height=5.5}
```{r, fig.width=9, fig.height=5.5}
sv_dependence(shp, v = x) # patchwork object
```

Expand Down

0 comments on commit 564c986

Please sign in to comment.