Is there an option to get a nice non italic greek letter (in my case "mu") in the axis label in R
with ggplot
and sans-serif
applied?
Left "mu": If I look closely it doesn't fit properly:
- wrong
font
(I could deal with that) - wrong
font
size
Right "mu":
- Just perfect, but I need it to be non-
italic
as it should be a unit
(Hint: In R-Studio preview window it is shown non-italic
, but I need the PDF to be correct.)
Here the R
-code:
library("ggplot2")
x <- seq(0,10,1)
y <- seq(0,1,0.1)
Data <- data.frame(x,y)
myPlot <- ggplot (Data, aes(x = x,y = y)) +
geom_point() +
scale_x_continuous(expression(paste("[", mu, "m] and [µm]")))+
theme(text = element_text(size=12, family="sans")) +
theme_minimal(); myPlot
ggsave("Test.pdf", width = 16, height = 8, units ="cm", dpi = 1200)
Update I: Output of the sessionInfo()
as it only appears on MacOs and not on Windows.
sessionInfo()
> R version 3.5.1 (2018-07-02)
> Platform: x86_64-apple-darwin15.6.0 (64-bit)
> Running under: macOS High Sierra 10.13.6
> Matrix products: default
> BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
> LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
> locale:
> [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
> other attached packages:
> [1] ggplot2_3.1.0
> loaded via a namespace (and not attached):
> [1] Rcpp_0.12.19 withr_2.1.2 assertthat_0.2.0 crayon_1.3.4 dplyr_0.7.7 R6_2.3.0
> [7] grid_3.5.1 plyr_1.8.4 gtable_0.2.0 magrittr_1.5 scales_1.0.0 pillar_1.3.0
> [13] rlang_0.3.0.1 lazyeval_0.2.1 rstudioapi_0.8 bindrcpp_0.2.2 labeling_0.3 tools_3.5.1
> [19] glue_1.3.0 purrr_0.2.5 munsell_0.5.0 yaml_2.2.0 compiler_3.5.1 pkgconfig_2.0.2
> [25] colorspace_1.3-2 tidyselect_0.2.5 bindr_0.1.1 tibble_1.4.2