mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2025-12-15 17:12:09 +01:00
feat: new default label for horizontal stacked plot
This commit is contained in:
parent
498ce52565
commit
81a1a2a870
2 changed files with 6 additions and 3 deletions
|
|
@ -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) +
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue