Reputation: 63
I want to change the labels using label_parsed in facet_grid but it is removing the scientific notation.
Here is a simple reproducible example:
library(ggplot2)
mtcars$cyl2 <- factor(mtcars$cyl,
labels = c('atop(atop(a),1.123e-2)','atop(atop(b),1e-3)','atop(atop(c),2.91e-4)'))
ggplot(mtcars, aes(wt, mpg)) + geom_point() + facet_grid(. ~ cyl2, labeller=label_parsed)
Although options("scipen"=-999, "digits"=4)
keeps the scientific notation for this example, it does not work in a more complex plot.
Upvotes: 1
Views: 337
Reputation: 263301
Do you just want this (using character instead of numeric arguments in the plotmath expressions:
mtcars$cyl2 <- factor(mtcars$cyl,
labels = c('atop(atop(a),"1.123e-2")','atop(atop(b),"1e-3")',
'atop(atop(c),"2.91e-4")'))
Upvotes: 2