连接图标题中的字符串和表达式 [英] Concatenate strings and expressions in a plot's title
本文介绍了连接图标题中的字符串和表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在情节标题中组合文本和数学表达式.如果我使用粘贴,则表达式将转换为字符.例如我想要这样的标题
How can I combine text and math expressions in a plot's title. If I use paste the expression is converted to character. For example I want something like this as a title
$S^2$ 的 $ARL_1$ 曲线
$ARL_1$ curve for $S^2$
谢谢
推荐答案
您想阅读 ?plotmath
以了解如何执行此类操作.下面是一个例子:
You want to read ?plotmath
to see how to do this sort of thing. Here is an example:
plot(1:10, main = expression(ARL[1] ~ "curve for" ~ S^2))
[.]
是下标,而 ^
是上标.~
将表达式的各个部分隔开,就像有文字空格一样.
The [.]
is subscript, whilst ^
gives superscript. The ~
spaces out the parts of the expression as if there were literal spaces.
编辑:通常我会这样做:
plot(1:10, main = expression(ARL[1] ~ curve ~ for ~ S^2))
但这会引发错误,因为 for
被解释为 for()
循环调用的开始.
but that throws an error because for
is being interpreted as the start of a for()
loop call.
这篇关于连接图标题中的字符串和表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文