Using Unicode inside R's [removed]) command

前端 未结 1 1591
醉酒成梦
醉酒成梦 2021-02-13 02:52

I\'m using expression() in R plots in order to get italicized text. But it appears as if I cannot use Unicode symbols inside expression outside of ASCI

相关标签:
1条回答
  • 2021-02-13 03:06

    You asked for a work-around. That is all this is. The italic part needs expression, but the "fi" part does not, so print them separately.

    plot.new()
    offset1 = strwidth(expression(paste(italic(m), "u")), units="figure")
    text(x =.5, y = .5, labels = expression(paste(italic(m), "u", sep="")))
    text(x =.5+offset1, y = .5, labels ="fi")
    offset2 = strwidth("fi ")
    text(x =.5+offset1+offset2, y = .5, labels = expression(italic(m)))
    

    But notice that something is not quite right about the spacing of the "fi", so when I computed the width on the screen, I cheated and computed the width of "fi " (with an extra blank). Without the extra spacing, the second italic(m) overlapped the "fi".

    Not pretty, but it produces the desired result under Windows.

    0 讨论(0)
提交回复
热议问题