简体   繁体   English

使用facet_grid隐藏垂直轴

[英]Hide vertical axis with facet_grid

How can I plot this without the information to the left of the graphs? 没有图表左侧的信息,如何绘制呢? Ie "wt" and its numbers should not be visible. 即“ wt”及其数字应不可见。 Graphs must remain intact. 图形必须保持不变。 Information under and to the right of the graphs should be visible. 图形下方和右侧的信息应可见。

library(ggplot2)
p <- ggplot(mtcars, aes(x=mpg, y=wt))
p <- p + geom_point()
p <- p + facet_grid(cyl ~ ., scales="free_y")
p

From reading other questions and answers here on SO, I suppose theme_blank() could be used, but not sure where to place it with facet_grids. 通过阅读SO上的其他问题和答案,我认为可以使用theme_blank(),但不确定将facet_grids放在哪里。

This should do it. 这应该做。

p + scale_y_discrete(breaks=NULL) + ylab("")

Edit: The solution above changes scales back (ignores "free" option). 编辑:上面更改的解决方案将缩小(忽略“免费”选项)。 How about this? 这个怎么样?

p + theme(axis.ticks.y = element_blank(), axis.text.y=element_blank(), 
            axis.title.y = element_blank())

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

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