0

Mathematical expressions for facets used to work just right when using something like labeller=as_labeller(old=expression(paste("Concentration (ng g"^"-1",")")). Now, I had to do something different to get the same results. There are some old posts 1,2 saying that in new versions some options no longer work so I want to know if that is the case here or there is something wrong with my system.

data(environmental) #lattice package
environmental_long<-environmental%>%
  dplyr::mutate(day=seq(1,length(environmental$ozone),by = 1))%>%
  tidyr::gather(key = "all_variables_name",value="values_variable",1:4)
environmental_long$names<-plyr::revalue(environmental_long$all_variables_name,c("ozone"="hat(x)~ozone~concentration(ppb)~'\u2030'"))

ggplot(environmental_long,aes(x=day,y=values_variable,colour=all_variables_name))+
  geom_point()+
  geom_smooth()+
  facet_wrap(names~.,scales = "free_y", strip.position = "left", #switch = "y"  for facet_wrap
             labeller = label_parsed
  )+
  theme_bw()+
  theme(legend.position = "none",
        strip.placement = "outside",
        axis.title.y = element_blank(),
        strip.background = element_rect(fill="white"))

The plot I want to get

  • wondering if you tried this https://stackoverflow.com/a/55438500/786542? – Tung Nov 09 '20 at 10:35
  • 1
    @Tung yes, it works perfectly. I am just a bit confused about the old way I used to use `expression(paste())` because now it is not showing the new text including superscripts or subscripts. Also, if it is better to use the option you mentioned or use `~` after each element of the new label so, in future plots, I don't face the same problem. – RobertoSupe Nov 10 '20 at 03:39

0 Answers0