r - 如何在与 `bquote` 一起使用的 `text` 表达式中换行?

标签 r data-visualization plotmath

我想在我的 bquote 中有一个新行环境,我该怎么做?

我的代码:

test<-c(1,2,3,4,4.5,3.5,5.6)
test2<-0.033111111
plot(test,c(1:length(test)))

segments(4,0,4,23,col="red",lwd=2)
text(5, 4.5, labels = bquote(Qua[0.99] == .(round(test2,4))),col="red", cex = 1.4)

我想在等号之后有一个新行,所以这应该给出:
VaR_0.99 =

0.03311

and not

    VaR_0.99 = 0.03311

我用线条试过了,但没有用:
    test<-c(1,2,3,4,4.5,3.5,5.6)
    test2<-0.033111111
    lines<-list(bquote(Qua[0.99] == ),bquote(.(round(test2,4))))
    plot(test,c(1:length(test)))

    segments(4,0,4,23,col="red",lwd=2)
    text(5, 4.5, labels =lines ,col="red", cex = 1.4)

最佳答案

例如,使用 atop :

test<-c(1,2,3,4,4.5,3.5,5.6)
test2<-0.033111111
plot(test,c(1:length(test)))

segments(4,0,4,23,col="red",lwd=2)
text(5, 4.5, 
     labels = bquote(atop(Qua[0.99] == phantom(), .(round(test2,4)))),
     col="red", cex = 1.4)

enter image description here

关于r - 如何在与 `bquote` 一起使用的 `text` 表达式中换行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15663535/

相关文章:

返回每组条件行的第一个值更改

r - 使用现有数据框创建新数据框

r - R & Ravelry 中的 API

r - ggplot2,为什么这么蓝?如何在渐变中设置不同的调色板

R/ggplot2 : Evaluate object inside expression

JavaScript D3 : overlapping of color areas

javascript - "Interpolate"不是一个函数

javascript - d3.js 在追加时不返回动态构造的 html 元素

r - 用绘图法保持尾随零