Using plotmath in ggplot2 with percent sign (%)

前端 未结 1 1971
花落未央
花落未央 2020-12-16 19:14

I would like to use Greek characters, Latin characters and the percent sign in the facet labels of a ggplot2 bar chart. Greek characters can be done with \'facet_grid(.~vari

相关标签:
1条回答
  • 2020-12-16 19:41

    Latin characters do not need any special treatment and you can see this in the first element of a. Try this:

    a<-c("Delta~V","VarcoV","'%'*V","Delta~V","VarcoV","'%'*V")
    

    The "%" sign is special so you need to quote it. You could have just done '%V' but I threw in the "*" (asterisk) to show how to separate plotmath tokens with no displayed space. (You already appear to know how to separate tokens with the spacing-separator, "~".)

    The key lesson is to mix type of quotes. The first quote type will signal which type is used to terminate the character token/string. You can also use the escape character: "\". This also succeeds:

    a<-c("Delta~V","VarcoV","\"%\"*V","Delta~V","VarcoV","\"%\"*V")
    
    0 讨论(0)
提交回复
热议问题