- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 ggplot
图中使用女性 ♀ 和男性 ♂ 符号。当我加载 extrafont
包并运行所需的代码时,它不起作用(类似于 post )。
我在 Mac OS X 版本 10.11.6 上使用 R for Mac OS X,版本 3.5.2。
install.packages("extrafont")
library(extrafont)
extrafont::loadfonts(device="pdf")
extrafont::font_import(pattern="CALIBRI") #pattern that has the ♀ and ♂ symbols
#when I run this as font_import() alone fonts() is still empty
错误信息:
Scanning ttf files in /Library/Fonts/, /System/Library/Fonts, ~/Library/Fonts/ ... Extracting .afm files from .ttf files... Error in data.frame(fontfile = ttfiles, FontName = "", stringsAsFactors = FALSE) : arguments imply differing number of rows: 0, 1
并仔细检查:
> fonts() #empty
NULL
> fonttable() #empty
data frame with 0 columns and 0 rows
有谁知道为什么会发生这种情况以及我如何才能让它正常运行?
更新:
或者,我可以使用不同的包加载 Calibri(参见 OP here)。但是,我仍然无法在我的 ggplot
上显示 ♀ 和 ♂ 符号。 建议?
install.packages('showtext', dependencies = TRUE)
library(showtext)
font_add_google("Montserrat", "Montserrat")
font_add_google("Roboto", "Roboto")
font_paths()
font_files()
# syntax: font_add(family = "<family_name>", regular = "/path/to/font/file")
font_add("Calibri", "calibri.ttf")
font_families()
showtext_auto()
最佳答案
showtext
应该能够完成这项工作。
library(ggplot2)
library(showtext)
showtext_auto()
female = intToUtf8(9792)
male = intToUtf8(9794)
p = ggplot() +
annotate("text", x = 1, y = 1, label = female, size = 20) +
annotate("text", x = 2, y = 1, label = male, size = 20) +
theme_bw(base_family = "sans")
## On screen
x11()
print(p)
## Save to PDF
ggsave("symbol.pdf", p, width = 9, height = 6)
关于r - 使用 ggplot2 的 extrafont 或 showtext 在 R 中导入女性和男性符号的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55483861/
我想在 QGLWidget 上显示工具提示,但我必须调用; QToolTip::showText(pos, "Message", qglwidgetPtr, rect(), 5000);在另一个类(c
我一直在使用 knitr 和 showtext 库来生成使用某些 Google 字体的 HTML 文件。在我将 R 升级到 3.4 之前,它一直运行良好。现在编织文档时,出现以下错误: Error:
我有一个自定义 View ,我试图在其中使用 Windows 字体 (calibri.ttf) 绘制文本。但是,我在使用 DrawString 和 ShowText 函数时得到了不同的行为。 我已将字
我正在尝试在 ggplot 图中使用女性 ♀ 和男性 ♂ 符号。当我加载 extrafont 包并运行所需的代码时,它不起作用(类似于 post )。 我在 Mac OS X 版本 10.11.6 上
我正在使用 s 样式组件返回一个 Material ui Fab 组件,但我在控制台中收到以下错误: React does not recognize the `showText` prop on a
我是一名优秀的程序员,十分优秀!