Greek letters in ggplot strip text

后端 未结 2 1776
醉梦人生
醉梦人生 2020-12-16 19:59

I\'m trying to override the text in some ggplot strips to incorporate Greek characters. Here\'s some sample data, and the base for the plot.

dfr <- data.         


        
2条回答
  •  醉梦人生
    2020-12-16 20:21

    posting this here since it's related:

    If you want the name of the variable itself as well as the levels/values of the variable to be evaluated as an expression (i.e. rendered as if they were latex), try this:

    label_parseall <- function(variable, value) {
        plyr::llply(value, function(x) parse(text = paste(variable, 
            x, sep = "==")))
    }
    

    Example:

    data <- data.frame(x = runif(10), y = runif(10), 
        gamma = sample(c("gamma[0]", "gamma[1]"), 10, rep = T))
    ggplot(data, aes(x, y)) + geom_point() + facet_grid(~gamma, 
        labeller = label_parselabel) 
    

    enter image description here

    image at http://img709.imageshack.us/img709/1168/parseall.png

提交回复
热议问题