我如何操纵facet_grid图的条形文字? [英] How can I manipulate the strip text of facet_grid plots?

查看:339
本文介绍了我如何操纵facet_grid图的条形文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在小平面图上操作条形文字的大小。我的问题
类似于关于情节标题的问题,但我特别关注
操作的不是情节标题,而是出现在方面标题(strip_h)中的文本。



作为示例,请考虑mpg数据集。

 库(ggplot2)
qplot(hwy,cty,data = mpg)+ facet_grid(。〜制造商)

由此产生的输出会产生一些不符合条带的分面标题。



我在想一定有办法使用 grid 来处理strip文本。但是我仍然是新手,并且无法从网格的附录中找到哈德利的书如何准确地做到这一点。此外,我害怕如果我做错了,它会打破我的洗钱
机器,因为我相信所有的技术都通过部队联系在一起: - (


提前感谢。

解决方案

您可以修改 strip.text.x (或 strip.text.y )使用 theme_text(),例如

  qplot(hwy,cty,data = mpg)+ 
facet_grid(。〜制造商)+
opts(strip.text.x = theme_text (size = 8,color =red,angle = 90))

for ggplot2 version> 0.9.1

  qplot(hwy,cty,data = mpg)+ 
facet_grid(。〜manufacturer)+
theme(strip.text.x = element_text(size = 8,color =red,angle = 90))


I'm wondering how I can manipulate the size of strip text in facetted plots. My question is similar to a question on plot titles, but I'm specifically concerned with manipulating not the plot title but the text that appears in facet titles (strip_h).

As an example, consider the mpg dataset.

    library(ggplot2) 
    qplot(hwy, cty, data = mpg) + facet_grid( . ~ manufacturer)

The resulting output produces some facet titles that don't fit in the strip.

I'm thinking there must be a way to use grid to deal with the strip text. But I'm still a novice and wasn't sure from the grid appendix in Hadley's book how, precisely, to do it. Also, I was afraid if I did it wrong it would break my washing machine, since I believe all technology is connected through The Force :-(

Many thanks in advance.

解决方案

You can modify strip.text.x (or strip.text.y) using theme_text(), for instance

qplot(hwy, cty, data = mpg) + 
      facet_grid(. ~ manufacturer) + 
      opts(strip.text.x = theme_text(size = 8, colour = "red", angle = 90))

Update: for ggplot2 version > 0.9.1

qplot(hwy, cty, data = mpg) + 
      facet_grid(. ~ manufacturer) + 
      theme(strip.text.x = element_text(size = 8, colour = "red", angle = 90))

这篇关于我如何操纵facet_grid图的条形文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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