【发布时间】:2018-07-11 05:38:07
【问题描述】:
我正在尝试使用包“xkcd”制作“xkcd”图。我按照vignette("xkcd-intro") 安装'xkcd'(字体和包)。我只需要添加font_import 的路径,否则会返回错误。
library(extrafont)
download.file("http://simonsoftware.se/other/xkcd.ttf",
dest="xkcd.ttf", mode="wb")
system("mkdir ~/.fonts")
system("cp xkcd.ttf ~/.fonts")
font_import(path="~/", pattern = "[X/x]kcd", prompt=FALSE)
loadfonts()
我确保字体中列出了“xkcd”
'xkcd' %in% fonts()
TRUE
我安装并导入了包'xkcd'
install.packages('xkcd')
require(xkcd)
我尝试了一个简单的情节
ggplot(mtcars, aes(x=mpg,y=wt)) + geom_point() // works fine
ggplot(mtcars, aes(x=mpg,y=wt)) + geom_point() + theme_xkcd() // Return following error
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
polygon edge not found
In addition: Warning messages:
1: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
no font could be found for family "xkcd"
2: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
no font could be found for family "xkcd"
3: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
no font could be found for family "xkcd"
4: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
no font could be found for family "xkcd"
5: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
no font could be found for family "xkcd"
你能帮我解决这个问题吗?
我在 Mac OS X 上
ProductVersion: 10.11.6
BuildVersion: 15G31
【问题讨论】:
标签: r macos ggplot2 fonts installation