feat: new default label for horizontal stacked plot

This commit is contained in:
Andreas Gammelgaard Damsbo 2025-10-06 12:57:50 +02:00
parent 498ce52565
commit 81a1a2a870
No known key found for this signature in database
2 changed files with 6 additions and 3 deletions

View file

@ -34,7 +34,8 @@ vertical_stacked_bars <- function(data,
t.size = 10,
l.color = "black",
l.size = .5,
draw.lines = TRUE) {
draw.lines = TRUE,
label.str="{n}\n{round(100 * p,0)}%") {
if (is.null(group)) {
df.table <- data[c(score, group, strata)] |>
dplyr::mutate("All" = 1) |>
@ -79,7 +80,8 @@ vertical_stacked_bars <- function(data,
y = p_prev + 0.49 * p,
color = as.numeric(score) > contrast_cut,
# label = paste0(sprintf("%2.0f", 100 * p),"%"),
label = sprintf("%2.0f", 100 * p)
# label = sprintf("%2.0f", 100 * p)
label = glue::glue(label.str)
)
) +
ggplot2::labs(fill = score_label) +

View file

@ -12,7 +12,8 @@ vertical_stacked_bars(
t.size = 10,
l.color = "black",
l.size = 0.5,
draw.lines = TRUE
draw.lines = TRUE,
label.str = "{n}\\n{round(100 * p,0)}\%"
)
}
\arguments{