Error using Arial in .eps figure with extrafont package

前端 未结 3 1661
臣服心动
臣服心动 2021-01-14 07:42

I\'m using ggplot2 in R to generate figures for a publication in which all figures need to be .eps format and all fonts needs to be Arial. I\'ve been following this guide to

3条回答
  •  Happy的楠姐
    2021-01-14 08:19

    Assuming you are on a Windows OS, you can alternatively create the graph using the showtext package.

    library(showtext)
    ## add the Arial font
    font.add("Arial", regular = "arial.ttf",
        bold = "arialbd.ttf", italic = "ariali.ttf", bolditalic = "arialbi.ttf")
    
    setEPS()
    postscript("some_graph.eps")
    showtext.begin() ## call this function after opening a device
    
    ggplot() + geom_point(aes(x=xvar, y=yvar)) +
        theme_minimal(base_family = "Arial")
    
    dev.off()
    

    The drawback is that you cannot use the ggsave() function, but instead call the device function by yourself.

    For the usage of the showtext package, a README is given at https://github.com/yixuan/showtext.

提交回复
热议问题