user2623214
user2623214

Reputation: 153

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?

Upvotes: 4

Views: 212

Answers (2)

David Arenburg
David Arenburg

Reputation: 92292

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)))

enter image description here

Upvotes: 2

Silence Dogood
Silence Dogood

Reputation: 3597

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

enter image description here

Upvotes: 0

Related Questions