我想在圖中顯示
我期待的改進:
Q1 : 如何在已使用的情況下將顏色更改為geom_text()黑色?scale_colour_manual()
Q2:如何才能只顯示在列variables中共享非零值的條中列的那些值value?
Q3:如何在那些計數低但標簽量大的條形圖上方獲得某種“放大鏡”效果?
uj5u.com熱心網友回復:
從資料集的描述來看,一個更美觀、更易讀的圖可能是這樣的:
fill_names %>%
filter(value != 0) %>%
mutate(variable = substr(variable, 5, 50),
value = ifelse(pol_dir == "Left", -value, value)) %>%
mutate(variable = case_when(
variable == "abort" ~ "Abortion",
variable == "anti_racism" ~ "Anti-Racism",
variable == "climate_change" ~ "Climate Change",
variable == "feminism" ~ "Feminism",
variable == "Gender" ~ "Gender Rights",
variable == "gun" ~ "Gun Rights",
variable == "left_wing" ~ "Left-wing rights",
variable == "LGBTQ_Gender" ~ "LGBTQ Gender rights",
variable == "right_wing" ~ "Right-wing rights")) %>%
select(-pol_dir) %>%
ggplot(aes(y = row_mean, x = value, fill = value > 0, alpha = count))
geom_point(alpha = 0)
geom_hline(yintercept = 0, alpha = 0.1)
geom_vline(xintercept = 0, alpha = 0.1)
geom_col(data = . %>% filter(value < 0), orientation = "y")
geom_col(data = . %>% filter(value >= 0), orientation = "y")
guides(fill = guide_none(), alpha = guide_none())
facet_wrap(.~variable)
scale_fill_manual(values = c("#0015BC", "#E9141D"))
scale_y_continuous(limits = c(-0.35, 0.35), name = "Mean score")
labs(title = "Importance of issues according to mean score on all questions",
subtitle = paste("Bar size shows mean score, density indicates",
"number of respondents at each mean score"))
theme_minimal(base_size = 16)
theme(panel.grid = element_blank(), panel.spacing.y = unit(8, "mm"),
strip.text = element_text(face = 2))
scale_x_continuous(limits = c(-0.6, 0.6), name = "Views on issue",
labels = c("", "Left wing", "", "Right wing", ""))

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/534936.html
標籤:r图表2几何条地理文本
上一篇:ggplot先前解決方案中的反向日期時間(POSIXct資料)軸損壞
下一篇:在ggplot中沿x軸添加空格
