How to have a new line in a `bquote` expression used with `text`?

后端 未结 3 790
滥情空心
滥情空心 2020-12-17 19:59

I want to have a new line in my bquote envrionment, how can I do this?

my code:

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


        
3条回答
  •  不思量自难忘°
    2020-12-17 20:44

    I wanted this but left aligned. After searching for solutions I ended up using two text() calls set up to put the text 0.25 inch apart and 0.25 in from top regardless of the plot dimensions.

    plot(1:100)
    r2 <- 40.2
    rmse <- 0.6
    ll = bquote(paste(italic(R)^2," = ",.(r2),"  RMSE = ",.(rmse)))
    val=0.25*diff(par('usr')[3:4])/par('pin')[2]
    text(par('usr')[1], par('usr')[4] - val, pos=4, labels=ll)
    text(par('usr')[1], par('usr')[4] - 2*val, pos=4, labels="Model A")
    

    Image produced by code

提交回复
热议问题