Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ggplot2:更改面网格打印中的strip.text位置_R_Plot_Ggplot2 - Fatal编程技术网

ggplot2:更改面网格打印中的strip.text位置

ggplot2:更改面网格打印中的strip.text位置,r,plot,ggplot2,R,Plot,Ggplot2,可以在打印区域内设置图例的位置,如 ... + theme(legend.justification=c(1,0), legend.position=c(1,0)) 是否有类似的简单方法来更改条形文本的位置 (或分组图中的因子水平) 库(2);图书馆(GG2) sp这里有一种方法: ggplot(tips, aes(x = total_bill, y = tip / total_bill)) + geom_point() + facet_grid(. ~ sex) + geom_t

可以在打印区域内设置图例的位置,如

... + theme(legend.justification=c(1,0), legend.position=c(1,0))
是否有类似的简单方法来更改条形文本的位置 (或分组图中的因子水平)

库(2);图书馆(GG2)
sp这里有一种方法:

ggplot(tips, aes(x = total_bill, y = tip / total_bill)) +
  geom_point() +
  facet_grid(. ~ sex) +
  geom_text(aes(label = sex), x = Inf, y = Inf, hjust = 1.5, vjust = 1.5) +
  theme(
      strip.background = element_blank(),
            strip.text = element_blank()
  )
然而,这并不是移动
strip.text
,而是添加
geom_text
元素并关闭
strip.background
strip.text
,但我认为它达到了预期的效果


您可以使用geom_text在图形上任意位置添加文本。Lavoie是的,thx,但是如何获取strip.text和绘图区域(在晶格中,如panel.number()和current.panel.limits())。。。我喜欢自动执行此操作,在这个确切的示例中不需要它,因为我知道strip.text和位置。如果您手动设置
scale\u x\u continuous
限制,您可以预测文本将下落的位置,并根据可以补偿的字符数调整水平位置。
ggplot(tips, aes(x = total_bill, y = tip / total_bill)) +
  geom_point() +
  facet_grid(. ~ sex) +
  geom_text(aes(label = sex), x = Inf, y = Inf, hjust = 1.5, vjust = 1.5) +
  theme(
      strip.background = element_blank(),
            strip.text = element_blank()
  )