r - ggplot2: Degree Celsius Symbol in labeller with dev="tikz" option in knitr -
i want put degree celsius symbol in ggplot2 labeller.mwe given below output:
library(ggplot2) ggplot(data=mtcars, mapping = aes(x=drat, y=mpg)) + geom_point() + facet_wrap(facets = ~cyl, labeller = as_labeller(c(`4` = "4 °c",`6` = "6 °c", `8` = "8 °c"))) however same strategy not work when dev="tikz" option used in knitr. figure out problem highly appreciated. thanks
it looks 1 option when working tikz device write math in native latex. \circ degree symbol, 1 of labels "$4^\\circ{c}$".
the following knits pdf dev = "tikz" , shows degree symbol:
ggplot(data=mtcars, mapping = aes(x=drat, y=mpg)) + geom_point() + facet_wrap(facets = ~cyl, labeller = as_labeller(function(string) paste0("$", string, "^\\circ{c}$"))) to add more spacing between number , degree symbol can include \\: or \\; in label.
labeller = as_labeller(function(string) paste0("$", string, "\\;^\\circ{c}$")) 
Comments
Post a Comment