有没有办法在ggarrange中包装剧情标题?

我正在尝试根据计划将学生通常来自哪个国家/地区可视化。由于每个程序的条形图需要具有不同的顺序,因此我选择了分别生成图形并通过ggarrange显示它们,如下所示:

有没有办法在ggarrange中包装剧情标题?

如您所见,地块标题被截断了。有办法解决吗?

我正在使用以下代码:

antal_hemvist_program<-function(x){totdata%>%filter(program==x)%>%ggplot(aes(x=fct_rev(fct_infreq(NYA_REGION))))+
geom_bar()+
theme(axis.title.y = element_blank(),axis.text.x=element_text(size=5))+ylab("Antal")+
coord_flip()+ggtitle(x)}

hv_n_program<-lapply(unique(totdata$program),antal_hemvist_program)

ggarrange(plotlist=hv_n_program)

数据摘要:

structure(list(program = c("IPPE","Ekonom","IPPE","Magister_FEK","Systemvetenskap","Magister_FIN","Webmaster","Maklarekonom","Animation","Digitala_Medier","Personalekonomi","Maklarekonom"),NYA_REGION = structure(c(3L,3L,4L,9L,2L,7L,8L,1L,5L,8L),.Label = c("UTANFÖR SVERIGE","ÖVRIGA LANDET","STORGÖTEBORG","oklart","SÖDRA BOHUSLÄN","UDDEVALLA","VÄSTERGÖTLAND","VÄNERSBORG","TROLLHÄTTAN","NORRA BOHUSLÄN","DALSLAND"),class = c("ordered","factor"))),row.names = c(NA,-50L),class = c("tbl_df","tbl","data.frame"))
lthusy 回答:有没有办法在ggarrange中包装剧情标题?

您可以在主题调用中添加plot.title.position = 'plot',这将使标题和字幕与整个情节而不是标题面板对齐。

antal_hemvist_program <- function(x {
  totdata %>%
  filter(program==x) %>%
  ggplot(aes(x=fct_rev(fct_infreq(NYA_REGION)))) +
    geom_bar() +
    theme(axis.title.y = element_blank(),axis.text.x=element_text(size=5),plot.title.position = 'plot') +
    ylab("Antal")+
    coord_flip()+ggtitle(x)}

enter image description here

本文链接:https://www.f2er.com/2535927.html

大家都在问