R italic partial title

情到浓时终转凉″ 提交于 2021-02-05 08:10:35

问题


a want to plot some graphs from for loop, where the main should be half italic and half normal. The code example should be

 a1<-1:20
 a2<-sample(a1)
 b1<-sample(a1)
 b2<-sample(a1)
 a<-list(a1, a2)
 b<-list(b1, b2)
 v<-c("a", "b")
 for(i in 1:2){
 jpeg(file=sprintf("%s.jpg", v[i]))
 plot(a[[i]], b[[i]], main=c("sas", v[i]))
 dev.off()}

but the v[i] should be in italic. I tried

 plot(a[[i]], b[[i]], main=c("sas", expression(italic(v[i]))))

but the second line of main is missing. Thx for any ideas!


回答1:


How about

 plot(a[[i]], b[[i]], main=bquote("sas"~italic(.(v[i]))))

That produces

Of if you realy wanted two lines, you could do

plot(a[[i]], b[[i]], main=bquote(atop("sas",italic(.(v[i])))))


来源:https://stackoverflow.com/questions/35630639/r-italic-partial-title

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