让我们先从条带函数开始。正如lattice中的高水平图形函数允许我们通过控制每个面板的
内容指定一个面板函数一样,条带函数可以自定义条带的方方面面。
请看如图23-1所示的曲线图。该图展示了按声部划分的纽约合唱团歌手的身高。图形的背景
是桃红色(抑或是粉橙色)。如果想让条带变成浅灰色,条带的文本变成黑色,字体变成斜体并
缩小20%该怎么办? 我们可以使用下面的代码来实现:
library(lattice)
histogram(~height | voice.part, data = singer,
strip = strip.custom(bg="lightgrey",
par.strip.text=list(col="black", cex=.8, font=3)),
main="Distribution of Heights by Voice Pitch",
xlab="Height (inches)")
option= 选 项 用 来 指 定 设 定 条 带 外 观 的 函 数 。 尽 管 我 们 可 以 从 头 写 一 个 函 数 ( 参
见?strip.default),但是改变一些设置并使用其他项的默认值更加简单。 strip.custom()
函数可以让我们实现这个功能。 bg选项控制了背景颜色, par.strip.text允许我们控制条带文
本的外观。
par.strip.text选项使用一个列表去定义文本属性。 col和cex控制文本的颜色和大小。
font选项可以分别取数值1、 2、 3和4,代表正常字体、粗体、斜体和粗斜体。








暂无数据