Labeling: Facet grid with multiple lines of text on y label

≡放荡痞女 提交于 2021-02-11 04:56:14

问题


I have a plotly graph made in ggplot2. I am displaying the graphics using face_grid but the y axis is very long. Because of this not all the words on the y axis are visible. Is there a way to split the text into two lines such that the entire y axis is visible?

majors.sub.HS<- majors.sub[, c(8:10, 66)] 

majors.sub.HS<-melt(majors.sub.HS, id.vars = "Major" )

majors.sub.HS$value[majors.sub.HS$value=="5- Highly Supported"] <- 5
majors.sub.HS$value[majors.sub.HS$value=="1- Not Supported"] <- 1

majors.sub.HS$value<- as.numeric (majors.sub.HS$value)

summary (majors.sub.HS)

p3<-ggplot(majors.sub.HS, aes(x=value, fill=Major)) +
        geom_bar(stat="count", alpha=0.85, color="black")  + facet_grid(variable~Major, scales='free_y')  + 
        theme_light() + scale_fill_brewer(palette="Dark2")
p3 <- ggplotly(p3)
p3

enter image description here

来源:https://stackoverflow.com/questions/51968039/labeling-facet-grid-with-multiple-lines-of-text-on-y-label

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!