Skip to content

Commit

Permalink
Remove grid lines (fix #32), change default in plot_pattern() to sq…
Browse files Browse the repository at this point in the history
…uare (#33)
  • Loading branch information
hanneoberman committed Mar 18, 2022
1 parent 1021cf8 commit ada2f51
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
4 changes: 3 additions & 1 deletion R/corr.R
Expand Up @@ -45,7 +45,9 @@ plot_corr <- function(data, vrb = "all", label = FALSE, square = TRUE, diagonal
gg <- gg + ggplot2::geom_text(color = "black", show.legend = FALSE, na.rm = TRUE)
}
if (square) {
gg <- gg + ggplot2::coord_fixed()
gg <- gg + ggplot2::coord_fixed(expand = FALSE)
} else {
gg <- gg + ggplot2::coord_cartesian(expand = FALSE)
}
if (rotate) {
gg <- gg + ggplot2::theme(axis.text.x.top = ggplot2::element_text(angle = 90))
Expand Down
4 changes: 3 additions & 1 deletion R/pattern.R
Expand Up @@ -87,7 +87,9 @@ plot_pattern <- function(data, vrb = "all", square = FALSE, rotate = FALSE, clus
) +
theme_minimice()
if (square) {
gg <- gg + ggplot2::coord_fixed()
gg <- gg + ggplot2::coord_fixed(expand = FALSE)
} else {
gg <- gg + ggplot2::coord_cartesian(expand = FALSE)
}
if (rotate) {
gg <- gg + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90))
Expand Down
6 changes: 4 additions & 2 deletions R/pred.R
Expand Up @@ -11,7 +11,7 @@
#' pred <- mice::make.predictorMatrix(mice::nhanes)
#' plot_pred(pred, label = TRUE)
#' @export
plot_pred <- function(data, label = FALSE, square = TRUE, rotate = FALSE) {
plot_pred <- function(data, label = TRUE, square = TRUE, rotate = FALSE) {
if (!is.matrix(data) | dim(data)[1] != dim(data)[2]) {
stop("Predictor matrix should be a square matrix, try using mice::make.predictorMatrix() or mice::quickpred().")
}
Expand All @@ -38,7 +38,9 @@ plot_pred <- function(data, label = FALSE, square = TRUE, rotate = FALSE) {
gg <- gg + ggplot2::geom_text(color = "black", show.legend = FALSE)
}
if (square) {
gg <- gg + ggplot2::coord_fixed()
gg <- gg + ggplot2::coord_fixed(expand = FALSE)
} else {
gg <- gg + ggplot2::coord_cartesian(expand = FALSE)
}
if (rotate) {
gg <- gg + ggplot2::theme(axis.text.x.top = ggplot2::element_text(angle = 90))
Expand Down
3 changes: 2 additions & 1 deletion R/theme.R
Expand Up @@ -25,7 +25,8 @@ theme_minimice <- function() {
legend.justification = "right",
strip.placement = "outside",
panel.grid.minor = ggplot2::element_blank(),
panel.grid.major = ggplot2::element_line(colour = "grey95"),
panel.grid.major = ggplot2::element_blank(),
axis.ticks = ggplot2::element_line(colour = "black"),
axis.title.y.right = ggplot2::element_text(margin = ggplot2::margin(l = 6))
)
}
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Expand Up @@ -30,7 +30,7 @@ Enhance a `mice` imputation workflow with visualizations for incomplete and/or i

## Installation

You can install the latest `ggmice` release from [CRAN](https://cran.r-project.org/) with:
You can install the latest `ggmice` release from [CRAN](https://CRAN.R-project.org/package=ggmice) with:

``` r
install.packages("ggmice")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -26,7 +26,7 @@ convergence, or compare observed versus imputed data.
## Installation

You can install the latest `ggmice` release from
[CRAN](https://cran.r-project.org/) with:
[CRAN](https://CRAN.R-project.org/package=ggmice) with:

``` r
install.packages("ggmice")
Expand Down
2 changes: 1 addition & 1 deletion man/plot_pred.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ada2f51

Please sign in to comment.