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

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

问题描述

我想知道如何在多面图中操纵条带文本的大小.我的问题类似于 关于情节标题的问题,但我特别关心不是操纵情节标题,而是操纵出现在构面标题 (strip_h) 中的文本.

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).

以 mpg 数据集为例.

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.

我认为必须有一种方法可以使用 grid 来处理条状文本.但是我仍然是新手,并不确定 grid 附录"nofollow noreferrer">Hadley 的书如何,准确地说,去做.还有,我怕我做错了会弄坏我的衣服机器,因为我相信所有的技术都是通过原力连接的:-(

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 :-(

非常感谢.

推荐答案

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

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))

更新: ggplot2 版本 > 0.9.1

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天全站免登陆