【问题标题】:title and text formatting in r - use simultaneously variables and superscriptr 中的标题和文本格式 - 同时使用变量和上标
【发布时间】:2013-05-30 13:10:08
【问题描述】:

我想在 R 中的经典(无 ggplot2)图形的标题中同时使用变量的值和数学格式。

我找到了一个解决方案,在标题中包含变量的内容,而不是上标。

number <- c('first','second','third')
plot(1:10,1:10)
title(main=paste(substitute(x,list(x=number[1])),' plot, units are in km m-3'))

我也找到了相反的解决方案:

plot(1:10,1:10)
title(main=expression(paste(number[1],' plot, units are in km ',m^{-3})))

然而,它是非常经验性的,因为我的大脑完全被所有这些表达概念、解析、引用、绘图、替代......

如果你比我更了解这一点,你会提出一个简单的解决方案吗?

谢谢,

弗朗索瓦

【问题讨论】:

    标签: r title plotmath


    【解决方案1】:

    bquote 的可能解决方案:

    plot(1:10, 1:10)
    title(main = bquote(.(number[1]) ~ "plot, units are in km" ~ m^-3))
    

    【讨论】:

    • 谢谢,我发现我们可以用“~”和bquote
    猜你喜欢
    • 2011-10-24
    • 1970-01-01
    • 2020-04-14
    • 1970-01-01
    • 2019-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-30
    相关资源
    最近更新 更多