r - Expression containing a comma as annotation on a single facet: is it possible? -
i interested in plotting customized expression contains comma on single facet of plot in ggplot2. know how plot expressions on single facet using new data frame follows:
fakedata <- data.frame(x = 1:10, y=runif(10), grp=gl(2,5)) ggplot(fakedata, aes(x=x,y,y)) + geom_point() + facet_grid(. ~ grp) + geom_text(data=data.frame(x=5,y=0.5,grp=1,lab='a == 5'), aes(label=lab), parse=true) i know how plot expressions on multiple facets using annotation_custom, can accommodate expression comma. not possible plot on single facet only.
ggplot(fakedata, aes(x=x,y,y)) + geom_point() + facet_grid(. ~ grp) + annotation_custom(grobtree(textgrob(expression(paste(a == 5, ', ', b == 6)), x=.5, y=.5))) but cannot figure out expression comma on single facet, since cannot store defined expressions in data frame. how can plot expression comma on single facet?
from ?plotmath, can use list() operator:
‘list(x, y, z)’: comma-separated list
g0 + geom_text(data=data.frame(x=5,y=0.5,grp=1,lab='list(a == 5, b==6)'), aes(label=lab), parse=true) 

Comments
Post a Comment