Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'grid' argument for plot_pattern, plot_pred, and plot_corr #135

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pepijnvink
Copy link
Collaborator

Based on #131. However, it does not solve the example.

@hanneoberman
Copy link
Member

Your solution does work, only the axis ticks are overlapping. Use this to remove:

ggmice::plot_pattern(data.frame(rbind(rep(NA, 100), 1:100)), grid = FALSE) + ggplot2::scale_x_discrete(breaks = 0)

@pepijnvink
Copy link
Collaborator Author

pepijnvink commented Feb 1, 2024

Your solution does work, only the axis ticks are overlapping. Use this to remove:

ggmice::plot_pattern(data.frame(rbind(rep(NA, 100), 1:100)), grid = FALSE) + ggplot2::scale_x_discrete(breaks = 0)

It may be useful to put this in a vignette or make it a separate statement (rather than default). Should choose whether to do only x, y, or both/together. In some cases, for example, it may be more useful to only remove the y axis breaks (if it is to improve visibility):

library(ggmice)
library(ggplot2)
# Simulate some example data
nvar <- 10
n <- 1000000
mat <- matrix(data = NA, nrow = n, ncol = nvar)
colnames(mat) <- paste0("V", 1:nvar)
set.seed(42)
for(i in 1:nvar){
  val <- sample(c(1, NA), size = n, replace = TRUE)
  val2 <- ifelse(!is.na(val), rnorm(n), NA)
  mat[,i] <- val2
}
df <- as.data.frame(mat) # save example data
ggmice::plot_pattern(df) +
  ggplot2::coord_cartesian(expand = FALSE) + # do not make square
  ggplot2::geom_raster() # remove grid lines
#> Coordinate system already present. Adding new coordinate system, which will
#> replace the existing one.

Created on 2024-02-01 with reprex v2.1.0

@pepijnvink
Copy link
Collaborator Author

Should also decide on axis titles when breaks are removed.

Instead of `ggplot2::geom_tile`. Avoids awkward coloring with many tiles.
@hanneoberman
Copy link
Member

Status check: discussed edits not all implemented yet, and conflicts with main. Converting to draft.

@hanneoberman hanneoberman marked this pull request as draft October 10, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants