3

I would like to have the title and axis legend in LM Roman 10 in my R plots, to better integrate them in my LateX text.

I have already tried this solution, but in R 4.1.2 does not work.

The code is the following (citing the answer to the previous question)

    # 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")

I have tried both on Windows 10 and macOS Monterey.

I have also tried to specify the full paths of the font folder.

What I see is a plot that either has the standard R font (in Windows) or has no text at all (in macOS).

Phil
  • 5,491
  • 3
  • 26
  • 61
vevvostar
  • 95
  • 8
  • 1
    Which part exactly didn't work for R 4.1.2. What code did you run? – MrFlick Mar 01 '22 at 16:19
  • @MrFlick the code in this answer: https://stackoverflow.com/a/35989404/11578991 without changing anything. Should I update my question? – vevvostar Mar 01 '22 at 16:35

0 Answers0