问题描述
有没有办法获取文本字符串的控制字符,例如""
用于 newline
在 plotmath 表达式中求值,反之亦然.在下面的例子中,我想结合:
- 一些字符文本
- 文本控制字符(换行符)
- 替换变量名
- 包含绘图数学表达式
在阅读这个问题后,我可以用替代来解决大部分问题,但是 与普通绘图不同,控制字符(例如)不会在 plotmath 中的字符串中解释. 这是否意味着它真的不可能? 正如你所想象的 Is there any way to get control characters for text strings, e.g. After reading this question I can get most of the way there with substitute, but the Does this mean it really is impossible? As you have figured 这篇关于在 plotmath 表达式中包含文本控制字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!换行符代码> 字符不被评估.我现在绕圈子,把自己弄糊涂了
plotmath
、parse
、bquote
和 substitute
.在 plotmath 的 帮助页面 中,它说 >lab = "一些数据"形式 = "指数"x = 1:10y = x^2绘图( x , y , type = "b" )标题(主要 = 替代(粘贴(Plot of",phi,of:",lab,
函数形式:",form),list(lab=lab,form=form)),adj=0)
plotmath
不支持换行符,但你可以使用 mtext
和 >bquote
,写每一行.例如,我创建了一个行列表:Lines <- list(bquote(paste( "Plot of " , phi , " of: " , .(lab))),bquote(paste("函数形式:" , .(form)))mtext(do.call(expression, Lines),side=3,line=1:0)
""
for newline
evaluated inside a plotmath expression, or vice versa. In the following example, I would like to combine:newline
character is not evaluated. I am now going round in circles and confusing myself with plotmath
, parse
, bquote
and substitute
. In the help page for plotmath it says lab = "some data"
form = "Exponential"
x = 1:10
y = x^2
plot( x , y , type = "b" )
title( main = substitute( paste( "Plot of " , phi , " of: " , lab , "
Functional form: " , form ) , list(lab = lab , form = form ) ) , adj = 0 )
plotmath
does not support newlines within, but you can use mtext
with bquote
, to write each line. For example I create a list of lines :Lines <- list(bquote(paste( "Plot of " , phi , " of: " , .(lab))),
bquote(paste("Functional form: " , .(form)))
mtext(do.call(expression, Lines),side=3,line=1:0)