2

我想在我的 R 图中有 LM Roman 10 中的标题和轴图例,以便更好地将它们集成到我的 LateX 文本中。

我已经尝试过这个解决方案,但在 R 4.1.2 中不起作用。

代码如下(引用上一个问题的答案)

    # Run once
install.packages("extrafont")
library(extrafont)
# Install **TTF** Latin Modern Roman fonts from www.fontsquirrel.com/fonts/latin-modern-roman
# Import the newly installed LModern fonts, change the pattern according to the 
# filename of the lmodern ttf files in your fonts folder
font_import(pattern = "lmroman*")


# Run each time
library(extrafont)
loadfonts(device = "win") # this line only in Windows
par(family = "LM Roman 10")
hist(c(1,2,3,4,5), xlab = "Some data", main = "A title")

我在 Windows 10 和 macOS Monterey 上都试过了。

我还尝试指定字体文件夹的完整路径。

我看到的是一个具有标准 R 字体(在 Windows 中)或根本没有文本(在 macOS 中)的图。

4

0 回答 0