gpt4 book ai didi

r - 在 ggplot2 中使用自定义 OTF 字体

转载 作者:行者123 更新时间:2023-12-02 04:18:11 24 4
gpt4 key购买 nike

我需要在 R 中使用 ggplot2 的自定义字体“Archer”。Archer 是安装在我的系统 (Mac OSX Yosemite) 上的 otf 字体。

此脚本(可在此处找到: Modifying fonts in ggplot2 )不适用于 Archer,但可以与其他字体(例如 Arial)配合使用。

install.packages("extrafont");library(extrafont)
font_import("Archer")
library(ggplot2)
qplot(1:10)+theme(text=element_text(family="Archer"))

otf 字体有什么问题吗?

最佳答案

您可以尝试showtext包,直接作用于 OTF 字体。

library(showtext)
font.add("Archer", "Archer.otf")
showtext.auto()
library(ggplot2)
qplot(1:10)+theme(text=element_text(family="Archer"))

请将“Archer.otf”替换为系统中您的 Archer 字体的真实文件名

使用showtext不需要嵌入字体。

关于r - 在 ggplot2 中使用自定义 OTF 字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30058107/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com