简体   繁体   English

在R中的图标题中同时使用下标和换行符

[英]Using subscript and line break at the same time in plot titles in R

I wish to include a subscript and a title running into two lines at the same time but am not getting desired result with following commands: 我希望同时包含一个下标和一个标题,同时将它们分成两行,但是使用以下命令并没有得到期望的结果:

base<-'B1'
compare<-'A1'
plot (1, 1, main = bquote('Annual mean' ~CO[2] ~'Flux Difference: \n'  ~.(compare)~ 'minus'~.(base)))

I wish to insert a line break after 'Flux Difference' but its not happening instead this term is hanging nowhere. 我希望在“磁通差异”之后插入一个换行符,但此情况并未发生,因此该术语没有任何用处。 Please help me. 请帮我。

Thanks, Munish 谢谢,穆尼什

This is a fairly common request and there is no really clean answer. 这是一个相当普遍的要求,没有一个真正明确的答案。 Plotmath will not accept a "\\n" (and the help page documents this.) One dodge is to use each line as an argument to the plotmath function atop . Plotmath将不接受“ \\ n”(帮助页面对此进行了说明。)闪避是将每一行用作top atop plotmath函数的参数。 The other plotmath trick sometimes of use is phantom with an empty argument list to allow the tilde not to throw an error, but that is not needed here: 有时使用的另一个plotmath技巧是带有空参数列表的phantom ,以允许代字号不引发错误,但是这里不需要这样做:

plot (1, 1, main = bquote( atop('Annual mean' ~CO[2] ~'Flux Difference:' , 
                                     .(compare)~ 'minus'~.(base))) )

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM