How can I add alpha-numeric AND greek characters to geom_text() in ggplot?

前端 未结 1 1050
执念已碎
执念已碎 2021-01-17 10:46

I am trying to create a plot that is annotated with text that contains both alpha-numeric and greek characters. If I want to add just greek characters I can use:

<         


        
相关标签:
1条回答
  • 2021-01-17 11:31

    One solution: substitute tildes ~ for spaces.

    d <- data.frame(x=1:3,y=1:3)
    qplot(x, y, data=d) + geom_text(aes(2, 2,
                  label="rho~and~some~other~text"), parse=TRUE)
    

    Substituting * for ~ works if you want to juxtapose without spaces.

    For the complete LaTeX solution I think you want to have a look at the tikzDevice package, possibly used in conjunction with knitr (the new coolest package on the block); e.g. see http://yihui.name/knitr/demo/graphics/

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