Reputation: 29
It seems that label_parsed
function does not work to show an expression for labels of figures in facet_grid
(see the figure bellow).
I expected that CO2 will show with subscript for 2. It did not and returned an error when I called the figure.
Error in parse(text = as.character(values)) : :1:10: unexpected numeric constant 1: Scenario 2 ^
However, when I removed one of variable 'impact' or 'ID' from the facet_grid() i.e. facet_grid(impact~., scales = "free", space = "fixed", labeller = label_parsed)
, then CO2 showed the subscript correctly.
What was wrong in my code? could anyone help me please? Thanks a lot in advance.
dat$impact <- factor(dat$impact,
labels = c('GHG(kg CO[2]-e)', 'Fossil fuel (MJ LHV)',
'Water stress (eq L)'))
f <- ggplot(dat, aes(impact, value), fill = stage) +
facet_grid(impact~ID, scales = "free", space = "fixed",
labeller = label_parsed) +
scale_colour_brewer("clarity")+
theme(
axis.title.x = element_blank(),
axis.text.x = element_blank(),
axis.ticks.x = element_blank())
f
Upvotes: 0
Views: 584