【问题标题】:Getting rid of facet_grid labels on those gray boxes?摆脱那些灰色盒子上的 facet_grid 标签?
【发布时间】:2015-05-31 22:50:51
【问题描述】:

我希望删除右侧的那些标签,即侧面灰色框上的标签。我举个例子:

p <- ggplot(mtcars, aes(mpg, wt, col=factor(cyl))) + geom_point()
p + facet_grid(cyl ~ .)

提前致谢!

胡安

【问题讨论】:

标签: r plot ggplot2 label facet


【解决方案1】:

以下内容会这样做:

p <- ggplot(mtcars, aes(mpg, wt, col=factor(cyl))) + geom_point()
p <- p + facet_grid(cyl ~ .)
p <- p +theme(strip.text.y = element_blank())

没有矩形

p <- ggplot(mtcars, aes(mpg, wt, col=factor(cyl))) + geom_point()
p <- p + facet_grid(cyl ~ .)
p <- p + theme(strip.background = element_blank(),
   strip.text.y = element_blank())

【讨论】:

  • 可能是这样的? ggplot(mtcars, aes(mpg, wt, col=factor(cyl))) + geom_point() + facet_grid(cyl ~ .) + theme(strip.text.y = element_blank(), strip.background = element_blank())
  • 这个指针不错,但是边上还是有灰色的矩形,有什么办法可以抹掉吗?
  • 不错的@FredrikKarlsson!就是这样。
  • @Fredrik Karlsson:谢谢你的建议,我在答案框中更新了,如果你当然允许的话;-)
  • 是我还是这不适用于以下内容(摘自 ggplot 手册):ggplot(economics_long, aes(date, value)) + geom_line() + facet_wrap(~variable, scales = "free_y", nrow = 2) + theme(strip.background = element_blank(), strip.text.y = element_blank())
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多