【发布时间】:2019-05-09 03:08:09
【问题描述】:
是否有一个选项可以在R 的轴标签中使用ggplot 和sans-serif 获得一个漂亮的非斜体希腊字母(在我的情况下为“mu”)?
左“mu”:如果我仔细看它不合适:
- 错误的
font(我可以处理) -
font大小错误
右“亩”:
- 完美,但我需要它不是
italic,因为它应该是一个单位
(提示:在 R-Studio 预览窗口中显示的不是italic,但我需要正确的 PDF。)
这里是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)
更新 I:sessionInfo() 的输出,因为它只出现在 MacO 上而不出现在 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
【问题讨论】:
-
它在我用你的代码得到的pdf中以“非斜体”字符显示...
-
您能否将
sessionInfo()的输出添加到您的帖子中,可能是操作系统特定的字体问题? -
在我的 windows 机器上它也不是
italic。 -
我在上面的代码中添加了
sessionInfo()。
标签: r macos ggplot2 fonts typography