Here is the issue: I am using ggplot
to to make a graph in which the x axis ranges from -90 to 90 degrees. I have successfully used a function to add degree sym
I read a comment here that mentions that labels take a character value. The output of your function was an expression. Changing add_degree()
to the following outputs character values instead of an expression and seems to work for me:
add_degree <- function(x) {
paste(x, "º",sep = "")
}
Here is my output for sessionInfo()
R version 3.0.3 (2014-03-06)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] ggplot2_1.0.0
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 digest_0.6.4 grid_3.0.3
[4] gtable_0.1.2 labeling_0.2 MASS_7.3-31
[7] munsell_0.4.2 plyr_1.8.1 proto_0.3-10
[10] Rcpp_0.11.1 reshape2_1.4 scales_0.2.4
[13] stringr_0.6.2 tools_3.0.3
I'm reusing the function taken from a similar question, which only requires a little adjustment.
make_labels <- function(value) {
x <- as.character(value)
do.call(expression, lapply(x, function(y) bquote(bold(.(y))^degree)))
}
Now, in your ggplot
call instead of add_degree
use labels = make_labels
and you'll get