简体   繁体   English

在 ggplot 2 中,facet_wrap 变量名没有出现在多面图上

[英]in ggplot 2 the facet_wrap variable name is not appearing on the faceted graph

When I am rendering the following code I am getting the correct graph, however, the label of the faceted variable assembly_no does not appear on the graph.但是,当我渲染以下代码时,我得到了正确的图形,但多面变量 assembly_no 的 label 没有出现在图形上。 下图

hp %>% 
  filter(assembly_no > 10) %>%  
  filter(position == 1) %>% 
  count(assembly_no, party) %>% 
  mutate(party = fct_reorder(party,n)) |> 
  mutate(assembly_no = as.factor(assembly_no)) |> 
  ggplot(aes(n, party, fill = party)) + 
  geom_col(width = 0.3, show.legend = FALSE) +
  facet_wrap(~assembly_no,
             labeller = "label_value",

             scales = "free_y" )+

  labs(x = "Total number of seats", 
       y = "Political Party", 
       title = "Total number of seats by political parties")

Created on 2022-09-07 by the reprex package (v2.0.1)reprex package (v2.0.1) 于 2022 年 9 月 7 日创建

What theme do you use?你用什么主题? What you show is not the default one.你显示的不是默认的。 It's possible that the labels are hidden by the theme.标签可能被主题隐藏了。

Check if you have a line with theme_set anywhere in your code.检查您的代码中是否有带有theme_set的行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM