简体   繁体   中英

greek symbol for axis label in R zoo plot

I am trying to plot a zoo series with a Greek symbol as the axis label.

Here is the code:

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

Any ideas why?

It seems like a bug to me, because as I said in comments, even

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

works. I think you should report it to the zoo package maintainers

The only way I could make it work is using title

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

在此输入图像描述

you could try

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

if you do traceback(), you can see that it the issue is in title function from help ?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

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM