r-quantities / units

Measurement units for R
https://r-quantities.github.io/units
175 stars 28 forks source link

Latin letter stand-ins should be typeset as their Greek counterparts in plots #238

Closed ekatko1 closed 4 years ago

ekatko1 commented 4 years ago

In the current implementation units such as micrometers are displayed in Latin: um instead of the Greek [mu]m when plotting. I have not tested other symbols with Greek letters but I assume that the problem is more general.

library(units)
library(ggplot2)
library(ggforce)

df = cars
df$Distance = set_units(df$dist, ft)/1000
df$Speed = set_units(df$speed, mph)

qplot(x=Speed, y=Distance, data=df) +
  scale_y_unit(unit = "um") 
# The Y-axis labels uses the latin u instead of the Greek mu
edzer commented 4 years ago

What is wrong with

qplot(x=Speed, y=Distance, data=df) +
   scale_y_unit(unit = "μm") 
ekatko1 commented 4 years ago

It doesn't seem to work for me:

Error: In ‘µm’, ‘µm’ is not recognized by udunits.
See a table of valid unit symbols and names with valid_udunits().
Add custom user-defined units with install_symbolic_unit().
edzer commented 4 years ago

what is your sessionInfo()?

ekatko1 commented 4 years ago
R version 3.5.1 (2018-07-02)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252   
[3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.1252    

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

other attached packages:
[1] ggforce_0.3.1 ggplot2_3.1.0 units_0.6-2  

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2       rstudioapi_0.8   magrittr_1.5    
 [4] MASS_7.3-51.4    tidyselect_0.2.5 munsell_0.5.0   
 [7] colorspace_1.3-2 R6_2.3.0         rlang_0.4.0     
[10] plyr_1.8.4       dplyr_0.8.3      tools_3.5.1     
[13] grid_3.5.1       packrat_0.5.0    gtable_0.2.0    
[16] withr_2.1.2      lazyeval_0.2.1   assertthat_0.2.0
[19] tibble_2.1.3     crayon_1.3.4     farver_2.0.1    
[22] tweenr_1.0.1     purrr_0.2.5      glue_1.3.0      
[25] labeling_0.3     polyclip_1.10-0  compiler_3.5.1  
[28] pillar_1.3.1     scales_1.0.0     pkgconfig_2.0.2 
edzer commented 4 years ago

Wow. Have you tried with a more recent release of R?

ekatko1 commented 4 years ago

Awesome, it works!! I wonder which R version started supporting the larger character set.