fefat: fixed Euler plotting without axis text

This commit is contained in:
Andreas Gammelgaard Damsbo 2025-08-08 11:49:09 +02:00
parent ca65bca2f8
commit 62b5d7a668
No known key found for this signature in database
5 changed files with 18 additions and 6 deletions

View file

@ -76,6 +76,7 @@ ggeulerr <- function(
#' D = sample(c(TRUE, FALSE, FALSE, FALSE), 50, TRUE) #' D = sample(c(TRUE, FALSE, FALSE, FALSE), 50, TRUE)
#' ) |> plot_euler("A", c("B", "C"), "D", seed = 4) #' ) |> plot_euler("A", c("B", "C"), "D", seed = 4)
#' mtcars |> plot_euler("vs", "am", seed = 1) #' mtcars |> plot_euler("vs", "am", seed = 1)
#' mtcars |> plot_euler("vs", "am", "cyl", seed = 1)
plot_euler <- function(data, pri, sec, ter = NULL, seed = 2103) { plot_euler <- function(data, pri, sec, ter = NULL, seed = 2103) {
set.seed(seed = seed) set.seed(seed = seed)
if (!is.null(ter)) { if (!is.null(ter)) {
@ -90,10 +91,9 @@ plot_euler <- function(data, pri, sec, ter = NULL, seed = 2103) {
na.omit() |> na.omit() |>
plot_euler_single() plot_euler_single()
}) })
# browser()
# names(out)
wrap_plot_list(out,title=glue::glue("Grouped by {get_label(data,ter)}")) wrap_plot_list(out,title=glue::glue("Grouped by {get_label(data,ter)}"))
# patchwork::wrap_plots(out, guides = "collect") # patchwork::wrap_plots(out)
} }
#' Easily plot single euler diagrams #' Easily plot single euler diagrams
@ -123,8 +123,8 @@ plot_euler_single <- function(data) {
legend.position = "none", legend.position = "none",
# panel.grid.major = element_blank(), # panel.grid.major = element_blank(),
# panel.grid.minor = element_blank(), # panel.grid.minor = element_blank(),
# axis.text.y = element_blank(), axis.text.y = ggplot2::element_blank(),
# axis.title.y = element_blank(), axis.title.y = ggplot2::element_blank(),
text = ggplot2::element_text(size = 20), text = ggplot2::element_text(size = 20),
axis.text = ggplot2::element_blank(), axis.text = ggplot2::element_blank(),
# plot.title = element_blank(), # plot.title = element_blank(),

View file

@ -7,6 +7,7 @@
#' #'
#' @examples #' @examples
#' mtcars |> plot_hbars(pri = "carb", sec = "cyl") #' mtcars |> plot_hbars(pri = "carb", sec = "cyl")
#' mtcars |> plot_hbars(pri = "carb", sec = "cyl", ter="am")
#' mtcars |> plot_hbars(pri = "carb", sec = NULL) #' mtcars |> plot_hbars(pri = "carb", sec = NULL)
plot_hbars <- function(data, pri, sec, ter = NULL) { plot_hbars <- function(data, pri, sec, ter = NULL) {
out <- vertical_stacked_bars(data = data, score = pri, group = sec, strata = ter) out <- vertical_stacked_bars(data = data, score = pri, group = sec, strata = ter)

View file

@ -111,6 +111,7 @@ mtcars |> plot_box_single("mpg")
mtcars |> plot_box_single("mpg","cyl") mtcars |> plot_box_single("mpg","cyl")
gtsummary::trial |> plot_box_single("age","trt") gtsummary::trial |> plot_box_single("age","trt")
mtcars |> plot_hbars(pri = "carb", sec = "cyl") mtcars |> plot_hbars(pri = "carb", sec = "cyl")
mtcars |> plot_hbars(pri = "carb", sec = "cyl", ter="am")
mtcars |> plot_hbars(pri = "carb", sec = NULL) mtcars |> plot_hbars(pri = "carb", sec = NULL)
mtcars |> mtcars |>
default_parsing() |> default_parsing() |>

View file

@ -31,4 +31,5 @@ data.frame(
D = sample(c(TRUE, FALSE, FALSE, FALSE), 50, TRUE) D = sample(c(TRUE, FALSE, FALSE, FALSE), 50, TRUE)
) |> plot_euler("A", c("B", "C"), "D", seed = 4) ) |> plot_euler("A", c("B", "C"), "D", seed = 4)
mtcars |> plot_euler("vs", "am", seed = 1) mtcars |> plot_euler("vs", "am", seed = 1)
mtcars |> plot_euler("vs", "am", "cyl", seed = 1)
} }

View file

@ -9,6 +9,9 @@ wrap_plot_list(
tag_levels = NULL, tag_levels = NULL,
title = NULL, title = NULL,
axis.font.family = NULL, axis.font.family = NULL,
guides = "collect",
axes = "collect",
axis_titles = "collect",
... ...
) )
} }
@ -19,7 +22,13 @@ wrap_plot_list(
\item{title}{panel title} \item{title}{panel title}
\item{...}{ignored for argument overflow} \item{guides}{passed to patchwork::wrap_plots()}
\item{axes}{passed to patchwork::wrap_plots()}
\item{axis_titles}{passed to patchwork::wrap_plots()}
\item{...}{passed to patchwork::wrap_plots()}
} }
\value{ \value{
list of ggplot2 objects list of ggplot2 objects