【发布时间】:2019-02-20 12:04:29
【问题描述】:
我正在创建一个图表并想更改标题和副标题的字体。
我希望标题为 Futura 粗体,副标题为 Futura 普通。
# Get the mtcars dataset to create some example plots
data(mtcars)
df <- mtcars[, c("mpg", "cyl", "wt")]
# Convert cyl to a factor variable
df$cyl <- as.factor(df$cyl)
# Plot
ggplot(data = mtcars, aes(x = wt, y = mpg)) +
geom_point() +
ggtitle('Basic Scatter Chart', subtitle = 'New ggplot theme') +
theme(
# Set title
plot.title = ggplot2::element_text(family='Futura',
size=20,
face='bold',
color="#222222"),
plot.subtitle = ggplot2::element_text(family= 'Futura',
face='plain',
size=16,
margin=ggplot2::margin(9,0,9,0)))
这给了我以下错误:
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 "Futura"
2: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
no font could be found for family "Futura"
如果我将 face 参数从普通更改为粗体,则情节有效,因此 R 似乎找不到 Futura 字体的普通变体。当我查看字体手册时,我可以看到中等、中等斜体、粗体。
对于其他使用 face plain 的字体(例如 Helvetica),它们在字体手册中有一个常规变体。
如何纠正这个问题以使 Futura 的普通变体正常工作?我不能只在 R 中将 medium 分配给 plain 吗?
【问题讨论】: