更改格子图中条带上的文本
如何更改格子图中显示的文本? 例子: 假设我有一个由 3 列组成的数据框测试,
x
[1] 1 2 3 4 5 6 7 8 9 10
y
[1] "A" "A" "A" "A" "A" "B" "B" "B" "B" "B"
a
[1] -1.9952066 -1.7292978 -0.8789127 -0.1322849 -0.1046782 0.4872866
[7] 0.5199228 0.5626998 0.6392686 1.6604549
对格子图的正常调用
xyplot(a~x | y,data=test)
将在条带上显示带有文本“A”和“B”的图,
如何在条带上写入不同的文本?
尝试使用另一个字符向量
z
[1] "a" "a" "a" "a" "a" "b" "b" "b" "b" "b"
并调用 strip.custom()
xyplot(a~x | y,data=test,strip=strip.custom(var.name=z))
不会给出所需的结果。
实际上这是一个国际化问题。
how do I change the text displayed in the strips of lattice plots?
example:
suppose I have a data frame test consisting of 3 columns
x
[1] 1 2 3 4 5 6 7 8 9 10
y
[1] "A" "A" "A" "A" "A" "B" "B" "B" "B" "B"
a
[1] -1.9952066 -1.7292978 -0.8789127 -0.1322849 -0.1046782 0.4872866
[7] 0.5199228 0.5626998 0.6392686 1.6604549
a normal call to a lattice plot
xyplot(a~x | y,data=test)
will give the plot with the Text 'A' and 'B' on the strips
How can I get different texts written on the strips?
An attept with another character vector
z
[1] "a" "a" "a" "a" "a" "b" "b" "b" "b" "b"
and a call to strip.custom()
xyplot(a~x | y,data=test,strip=strip.custom(var.name=z))
does not give the desired result.
In reality it is an internationalization problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为你想要的可以通过以下方式获得:
I think what you want can be obtained by:
如果您将字符向量作为一个因素,那么您只需更改级别即可:
If you make your character vector a factor then you can just change the levels:
这是一个老问题,但我最近因为带状疱疹和因素而苦苦挣扎。以下是使用地震数据集的两种情况的示例。
作为带状疱疹,使用
strip = strip.custom(strip.names=FALSE, strip.levels=TRUE)
仅显示垃圾箱。使用as.table = TRUE
对面板进行渐进排序。使用木瓦可将色条保留在条带中。作为一个因素,条带名称是自动的。
This is an old question, but I recently was struggling with this for shingles and factors. Here is an example for both cases using the quakes dataset.
As shingles, use
strip = strip.custom(strip.names=FALSE, strip.levels=TRUE)
to just show the bins. Useas.table = TRUE
to sort the panels progressively. Using shingles retains the color bar in the strip.As a factor, the strip name automatic.