代码之家  ›  专栏  ›  技术社区  ›  ClimateUnboxed

R如何在文本上标前加括号得到上标

r
  •  1
  • ClimateUnboxed  · 技术社区  · 7 年前

    plot(c(1,2),c(1,2),type='n',xlab=expression("example " (m^2)))
    

    从这几页来看,这个很好用

    How do I include a superscript to texts on a plot on R?

    Superscript in R

    但是我想有一个标签,上面写着(^o C),其中^o是升度数符号。尝试删除m部分总是会给我一个错误:

    unexpected '^'
    
    2 回复  |  直到 7 年前
        1
  •  2
  •   missuse    7 年前

    你可以用

    plot(c(1,2),c(1,2),type='n',xlab=expression("example " (degree~C)))
    

    enter image description here

    或者如果度和C之间不需要空格

    plot(c(1,2),c(1,2),type='n',xlab=expression("example " (degree*C)))
    

    enter image description here

    详情请查收

    ?plotmath
    
        2
  •  1
  •   mt1022    7 年前

    plot(c(1,2),c(1,2),type='n',xlab=expression("example " (paste(""^o, "C"))))
    

    enter image description here