问题
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