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"))) 

enter image description here

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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -