Nov*_*ova 6 fonts r ggplot2 plotmath
我试图在我的情节中使用女性符号♀.它非常微弱(嗯,它在我的实际图形上看起来很微弱),所以我希望能让它变得大胆.
df <- data.frame(x = c(0, 1), y = c(0, 1))
ggplot(df, aes(x, y)) + geom_point() +
theme_bw() +
annotate("text", x = 0.5, y = 0.7, label = "2016 ?",
size = 7, hjust = 0, colour = "grey50")
Run Code Online (Sandbox Code Playgroud)
我尝试了以下,但似乎没有工作:
ggplot(df, aes(x, y)) + geom_point() +
annotate("text", x = 0.5, y = 0.7, label = "2016~bold(?)",
size = 7, hjust = 0, parse = TRUE)
# error message: Error in parse(text = as.character(lab)) : <text>:1:11: unexpected '<'
#1: 2016~bold(<
^
ggplot(df, aes(x, y)) + geom_point() +
annotate("text", x = 0.5, y = 0.7, label = "2016~bold(u2640)",
size = 7, hjust = 0, parse = TRUE)
ggplot(df, aes(x, y)) + geom_point() +
annotate("text", x = 0.5, y = 0.7, label = "2016~bold(\u2640)",
size = 7, hjust = 0, parse = TRUE)
Run Code Online (Sandbox Code Playgroud)
我也找到了这篇文章,但我不确定我是否可以修改以下代码在ggplot中工作?
plot(df)
text( locator(1), "\\VE", vfont=c("sans serif","bold"), xpd=TRUE) # Venus
Run Code Online (Sandbox Code Playgroud)
@Axeman的评论帮助我找到了答案-我不知道您可以加载其他软件包来获取ggplot2的更多字体。谢谢!我使用以下代码:
install.packages("extrafont")
library(extrafont)
font_import() # Prepare for this to take several minutes
loadfonts(device = "win")
ggplot(df, aes(x, y)) + geom_point() +
theme_bw() +
annotate("text", x = 0.5, y = 0.7, label = "2016 ?",
size = 7, hjust = 0, colour = "grey50", family = "Calibri", fontface = "bold")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2296 次 |
| 最近记录: |