在R的zoo图中,坐标轴标签的希腊符号

4

我正在尝试绘制一个带有希腊符号作为轴标签的动物园系列图。

以下是代码:

mu_val <- 1
plot(1:10,101:110,main=bquote(mu~'='~.(mu_val)))  ## works fine
plot(1:10,101:110,ylab=bquote(mu~'='~.(mu_val)))  ## works fine
plot(zoo(101:110,1:10),main=bquote(mu~'='~.(mu_val)))  ## works fine
plot(zoo(101:110,1:10),ylab=bquote(mu~'='~.(mu_val)))  ## gives error
## Error in title(...) : invalid mathematical annotation

有什么想法吗?

2
对我来说,这似乎是一个错误,因为即使 plot(zoo(101:110,1:10),xlab=bquote(mu~'='~.(mu_val))) 也可以工作。 - David Arenburg
你应该联系软件包维护者。 - agstudy
2个回答

2

在我看来,这似乎是一个bug,因为正如我在评论中所说,即使是

plot(zoo(101:110,1:10),xlab=bquote(mu~'='~.(mu_val)))

也可以工作。我认为你应该向zoo包的维护者报告此问题。

我唯一能让它工作的方法是使用title

plot(zoo(101:110,1:10),ylab="")
title(ylab = bquote(mu~'='~.(mu_val)))

enter image description here


0
你可以尝试:

plot(zoo(101:110,1:10),ylab=expression(paste(mu,"=1")))

如果你执行 traceback(),你可以看到问题出在从帮助函数 ?title 调用的 title 函数。
They must be of type character or expression. In the latter case, quite a bit of mathematical
notation is available such as sub- and superscripts, greek letters, fractions, etc: see plotmath

enter image description here


事实是我想让“=1”成为一个在运行时设置的变量。 - user2623214

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接