Martin Schmelzer
Martin Schmelzer

Reputation: 23889

Show characters and variable values in subtitle

I tried almost all combinations of paste(), bquote(), as.expression(), c(),...

plot(d[,"y"], type="l",xlim=c(1,n), ylim=c(min(d[,"y"]),max(d[,"y"])), 
  ylab="Y", xlab="T", main="ARMA(1,1)",
   sub=c(as.expression(bquote(phi == .(coef_ar)), 
         as.expression(bquote(theta == .(coef_ma))))))

This just plots "phi = 0.5" (the greek symbol in this case) but not the second part (the theta). Can anyone help me please!

Thanks!

Upvotes: 3

Views: 328

Answers (1)

mnel
mnel

Reputation: 115392

You can use substitute. ~ will concatenate together the expressions with a space

plot(1, main = substitute(phi == Phi ~ theta == Theta, list(Phi = 1, Theta = 1)))

enter image description here

or you can use bquote in a similar manner

plot(1, main = bquote(phi == .(coef_ar)  ~ theta == .(coef_ma)))

The reason your initial approach did not work is because it creates a vector of expressions, and then used only the first element for the subtitle.

If you want comma separated values, then use list(),

eg

 plot(1, main = bquote(list(phi == .(coef_ar), theta == .(coef_ma))))

Upvotes: 7

Related Questions