将文本在r

问题描述 投票:0回答:1

I具有与所述的HERE的相同模拟数据,而组2的差异具有大文本的元素。我想水平地将刻面中的文本翻转到顶部的刻面col条上,而不会消失。 我可以在r?

library(ggstats) library(dplyr) library(ggplot2) likert_levels <- c( "Strongly disagree", "Disagree", "Neither agree nor disagree", "Agree", "Strongly agree" ) df <- tibble( grouping = sample(c("A", "B", "C", "D"), 150, replace = TRUE), q1 = sample(likert_levels, 150, replace = TRUE), q2 = sample(likert_levels, 150, replace = TRUE, prob = 5:1), q3 = sample(likert_levels, 150, replace = TRUE, prob = 1:5), q4 = sample(likert_levels, 150, replace = TRUE, prob = 1:5), q5 = sample(c(likert_levels, NA), 150, replace = TRUE), q6 = sample(likert_levels, 150, replace = TRUE, prob = c(1, 0, 1, 1, 0)) ) %>% mutate(across(-grouping, ~ factor(.x, levels = likert_levels))) df gglikert(df, q1:q6, facet_cols = vars(grouping)) df_group <- df df_group$group1 <- sample(c("category A", "category B","category C"), 150, replace = TRUE) df_group$group2 <- sample(c("usa-new york", "usa-san fransisco", "usa-new orleans", "united kingdom-stratford upon avon", "south africa-port elizabeth", "new zealand-upper hutt city"), 150, replace = TRUE) gglikert(df_group, q3:q6, facet_cols = vars(group1), facet_rows = vars(group2), labels_size = 3 ) + scale_x_continuous( labels = label_percent_abs(), expand = expansion(0, .2) )

enter image description here 您可以使用

实现所需的结果
r ggplot2 likert
1个回答
0
投票

gglikert(df_group, q3:q6, facet_cols = vars(group1), facet_rows = vars(group2), labels_size = 3 ) + scale_x_continuous( labels = label_percent_abs(), expand = expansion(0, .2) ) + theme(strip.text.y = element_text(angle = 0))

enter image description here

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.