Search code examples
rplotlabelplotmath

Adding greek characters with variables to axis title


I have two vectors alpha <- c(1,2,3), beta <- c(4,5,6). I have three plots and each of them is using diferent alpha and beta (etc. first plot contains alpha[1] and beta[1])

Now I would like to add axis title to each graph like: "alpha = 1, beta = 4" with greek letters. How can I do it? I found a similar question so I tried some solutions from there, but:

with bquote() I can use only one = . So I can do

bquote(alpha == .(alpha[1]) * ", " * beta * .(beta[1])) do get alpha = 1, beta4

but I can't add another =

with expression(paste()) variables works like text, so instead of alpha = 1, I got alpha = alpha[1]

What is a correct way how to do it?


Solution

  • I'd try using a plotmath list call:

    plot(1,1, main= bquote(list( alpha == .(alpha[1]) ,  beta == .(beta[1])) )  )