3
ggplot(data = d1.6, aes(x = index, y = value, shape = variable)) +
  geom_point() +
  labs(x = "index", y = "tensile strength") +
  scale_shape_manual(name = "temperature", values = c(19, 5), labels = c("20°C", "40°C")) +
  theme(text = element_text(family = "Arial Unicode MS"))

> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.13.4 (unknown)

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] MASS_7.3-45    reshape2_1.4.3 ggplot2_3.0.0 

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.18     rstudioapi_0.7   bindr_0.1.1      magrittr_1.5     tidyselect_0.2.4
 [6] munsell_0.5.0    colorspace_1.3-2 R6_2.2.2         rlang_0.2.2      stringr_1.3.1   
[11] plyr_1.8.4       dplyr_0.7.6      tools_3.3.1      grid_3.3.1       gtable_0.2.0    
[16] withr_2.1.2      yaml_2.2.0       lazyeval_0.2.1   assertthat_0.2.0 digest_0.6.16   
[21] tibble_1.4.2     crayon_1.3.4     bindrcpp_0.2.2   purrr_0.2.5      glue_1.3.0      
[26] labeling_0.3     stringi_1.2.4    pillar_1.3.0     scales_1.0.0     pkgconfig_2.0.2 

Specifying a Unicode supportive font does not make Unicode characters display normally. In case you don't want to view the image, the characters (°) are replaced with "..".

enter image description here

Eureka Zheng
  • 331
  • 1
  • 2
  • 8
  • 1
    Welcome to SO. Your question is quite good for a newbie, but unfortunately not quite reproducible. Please provide us with some data for reproducibility purposes. https://stackoverflow.com/help/mcve. https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – tjebo Sep 03 '18 at 22:00
  • 1
    Other questions have brought this up before ([here's one](https://stackoverflow.com/q/51039262/5325862)) and it's often a system-specific issue. You didn't include a sample of data, but I made up a toy version of a similar task and, on macOS 10.13.6 running R 3.5.1 and `ggplot2` 3.0.0, I'm able to print degree symbols in scale labels – camille Sep 03 '18 at 22:10
  • @camille Thank you for your advice but the question you linked is not system-specific, and the poster was simply assuming "+-" to work. – Eureka Zheng Sep 04 '18 at 13:48
  • Yes, it's one of several questions that may help. The question isn't about unicode characters but the answer is, and it gives examples of using both a character representation (such as the degree sign) and a unicode sequence. I can't replicate the problem on my setup, and a lack of reproducibility comes up on other unicode-related questions because it tends to be system- or version-based – camille Sep 04 '18 at 14:03

1 Answers1

1

The problem is that my R locale is "C". By changing it to another option (Chinese):

system("defaults write org.R-project.R force.LANG zh_CN.UTF-8")

And relaunch RConsole, it works perfectly.

Eureka Zheng
  • 331
  • 1
  • 2
  • 8