消除一个轴上的strip.background(ggplot2) [英] Eliminate strip.background on one axis (ggplot2)

查看:483
本文介绍了消除一个轴上的strip.background(ggplot2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ggplot2中的许多主题元素都只有一个.x或.y扩展名,可以在一个轴上删除/更改某些内容。 strip.background 没有 strip.background.x 等价物,如下所示。

Many of the theme elements in ggplot2 have a .x or .y only extension to remove/alter something on only one axis. strip.background does not have a strip.background.x equivalent as can be seen below.

如何从一个坐标轴上的facet标签中删除文本和 strip.background

How can I remove the text and strip.background from the facet labels on only one axis?

a <- ggplot(mtcars, aes(mpg, hp)) +
    geom_point() +
    facet_grid(cyl~gear) 

a + theme(strip.text.y = element_blank(), 
    strip.background.x = element_blank())

##     > a + theme(strip.text.y = element_blank(), strip.background.x = element_blank())
##     Error in (function (el, elname)  : 
##       "strip.background.x" is not a valid theme element name.


推荐答案

至少对于ggplot2版本2.0.0。如果设置 strip.text.x = strip.text.y = element_blank()它删除特定轴的文本和背景。

At least for the ggplot2 version 2.0.0. if you set the strip.text.x= or strip.text.y= to element_blank() it removes text and the background for particular axis.

a + theme(strip.text. = element_blank())

这篇关于消除一个轴上的strip.background(ggplot2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆