mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2026-06-19 04:27:30 +02:00
fix: adjusted text size and text color
This commit is contained in:
parent
7b0692fd17
commit
46c6ed03ae
1 changed files with 6 additions and 7 deletions
|
|
@ -10,7 +10,7 @@
|
||||||
#' mtcars |> plot_hbars(pri = "carb", sec = "cyl", ter="am")
|
#' mtcars |> plot_hbars(pri = "carb", sec = "cyl", ter="am")
|
||||||
#' mtcars |> plot_hbars(pri = "carb", sec = NULL,color.palette="Blues")
|
#' mtcars |> plot_hbars(pri = "carb", sec = NULL,color.palette="Blues")
|
||||||
#' mtcars |> plot_hbars(pri = "carb", sec = NULL,color.palette="Magma")
|
#' mtcars |> plot_hbars(pri = "carb", sec = NULL,color.palette="Magma")
|
||||||
#' mtcars |> plot_hbars(pri = "carb", sec = NULL,color.palette="Viridis")
|
#' mtcars |> plot_hbars(pri = "carb", sec = "am",color.palette="Viridis")
|
||||||
plot_hbars <- function(data,
|
plot_hbars <- function(data,
|
||||||
pri,
|
pri,
|
||||||
sec,
|
sec,
|
||||||
|
|
@ -41,7 +41,7 @@ vertical_stacked_bars <- function(data,
|
||||||
score = "full_score",
|
score = "full_score",
|
||||||
group = "pase_0_q",
|
group = "pase_0_q",
|
||||||
strata = NULL,
|
strata = NULL,
|
||||||
t.size = 10,
|
t.size = 8,
|
||||||
l.color = "black",
|
l.color = "black",
|
||||||
l.size = .5,
|
l.size = .5,
|
||||||
draw.lines = TRUE,
|
draw.lines = TRUE,
|
||||||
|
|
@ -77,12 +77,12 @@ vertical_stacked_bars <- function(data,
|
||||||
if (isTRUE(reverse)) {
|
if (isTRUE(reverse)) {
|
||||||
colors <- rev(colors)
|
colors <- rev(colors)
|
||||||
}
|
}
|
||||||
contrast_cut <-
|
|
||||||
contrast_text(colors, threshold = .3) == "white"
|
|
||||||
|
|
||||||
score_label <- data |> get_label(var = score)
|
score_label <- data |> get_label(var = score)
|
||||||
group_label <- data |> get_label(var = group)
|
group_label <- data |> get_label(var = group)
|
||||||
|
|
||||||
|
# browser()
|
||||||
|
|
||||||
p |>
|
p |>
|
||||||
(\(.x) {
|
(\(.x) {
|
||||||
.x$plot +
|
.x$plot +
|
||||||
|
|
@ -94,7 +94,7 @@ vertical_stacked_bars <- function(data,
|
||||||
ggplot2::aes(
|
ggplot2::aes(
|
||||||
x = group,
|
x = group,
|
||||||
y = p_prev + 0.49 * p,
|
y = p_prev + 0.49 * p,
|
||||||
color = contrast_cut,
|
color = contrast_text(colors[as.numeric(score)], threshold = .3),
|
||||||
# label = paste0(sprintf("%2.0f", 100 * p),"%"),
|
# label = paste0(sprintf("%2.0f", 100 * p),"%"),
|
||||||
# label = sprintf("%2.0f", 100 * p)
|
# label = sprintf("%2.0f", 100 * p)
|
||||||
label = glue::glue(label.str)
|
label = glue::glue(label.str)
|
||||||
|
|
@ -103,8 +103,7 @@ vertical_stacked_bars <- function(data,
|
||||||
ggplot2::labs(fill = score_label) +
|
ggplot2::labs(fill = score_label) +
|
||||||
ggplot2::scale_fill_manual(values = colors) +
|
ggplot2::scale_fill_manual(values = colors) +
|
||||||
ggplot2::theme(legend.position = "bottom",
|
ggplot2::theme(legend.position = "bottom",
|
||||||
axis.title = ggplot2::element_text(),
|
axis.title = ggplot2::element_text(),) +
|
||||||
) +
|
|
||||||
ggplot2::xlab(group_label) +
|
ggplot2::xlab(group_label) +
|
||||||
ggplot2::ylab(NULL)
|
ggplot2::ylab(NULL)
|
||||||
})()
|
})()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue