ggplot条文本中的希腊字母 [英] Greek letters in ggplot strip text
本文介绍了ggplot条文本中的希腊字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试覆盖某些ggplot条带中的文本以合并希腊字符.这是一些示例数据,以及该图的基础.
I'm trying to override the text in some ggplot strips to incorporate Greek characters. Here's some sample data, and the base for the plot.
dfr <- data.frame(
x = rep(1:10, times = 6),
y = runif(60),
fx = rep(c("foo", "bar"), each = 30),
fy = rep(c("alpha", "beta", "gamma"), each = 10, times = 2)
)
p <- ggplot(dfr, aes(x, y)) + geom_point()
我第一次尝试绘图时,标签上没有希腊语.
My first attempt at a plot has no Greek in the strip labels.
p + facet_grid(fy ~ fx)
我认为应该在facet_grid
上添加一个labeller参数以覆盖文本.我以为这应该吐出一个表达式来处理希腊字符,但是在打印图形时,我的代码只会引发错误.
I gather that I'm supposed to add a labeller argument to facet_grid
to override the text. I presumed that this should spit out an expression to handle the greek characters, but my code just throws an error when the graphic is printed.
lbl <- function(variable, value)
{
if(variable == "fy") parse(text=as.character(value)) else value
}
p + facet_grid(fy ~ fx, labeller = lbl)
Error in aperm(X, c(s.call, s.ans)) :
unimplemented type 'expression' in 'aperm'
我应该如何创建带状标签?
How should I be creating the strip labels?
推荐答案
尝试一下:
p + facet_grid(fy ~ fx, labeller = label_parsed)
这篇关于ggplot条文本中的希腊字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文