如何组合图例中多个项目的表达式?
How to combine expressions for multiple items in a legend?
我似乎无法构建混合文本和表达式的图例。我需要使用 bquote
在表达式中放置一个值,但我似乎无法将它与图例中另一个项目的文本连接起来。例如:
legend_text <- "text"
beta <- 0.01 # this is a variable
if (beta > 0)
legend_text = c(bquote(beta == .(beta)), legend_text)
plot(1, type="n")
legend("topright", legend=legend_text, text.col="red") # doesn't work for two items
legend("bottomright", legend=bquote(beta == .(beta)), text.col="blue") # works as expected
有什么想法可以混合两个项目以获得预期的结果吗?
也许将整体作为表达式传递会起作用
plot(1, type="n")
legend("topright", legend=as.expression(legend_text), text.col="red")
legend("bottomright", legend=bquote(beta == .(beta)), text.col="blue") # works as expected
我似乎无法构建混合文本和表达式的图例。我需要使用 bquote
在表达式中放置一个值,但我似乎无法将它与图例中另一个项目的文本连接起来。例如:
legend_text <- "text"
beta <- 0.01 # this is a variable
if (beta > 0)
legend_text = c(bquote(beta == .(beta)), legend_text)
plot(1, type="n")
legend("topright", legend=legend_text, text.col="red") # doesn't work for two items
legend("bottomright", legend=bquote(beta == .(beta)), text.col="blue") # works as expected
有什么想法可以混合两个项目以获得预期的结果吗?
也许将整体作为表达式传递会起作用
plot(1, type="n")
legend("topright", legend=as.expression(legend_text), text.col="red")
legend("bottomright", legend=bquote(beta == .(beta)), text.col="blue") # works as expected