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

穿精又带淫゛_ 提交于 2020-01-01 19:25:22

问题


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


回答1:


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. 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:

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



来源:https://stackoverflow.com/questions/13317428/using-subscript-and-line-break-at-the-same-time-in-plot-titles-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!