library(extrafont) font_import()
# 暂且使用rTIMES # set_font() write_fig({ # plot(0) plot.new() str = "测试字体 Times New Roman" x = 0.5 cex = 1.2 text(x, 0.5, str, family = "song", offset = c(0,0), font = 2) text(x, 0.4, "(a) 华文仿宋 测试字体 Times New Roman Huawen Fangsong", family = "hwfsong", cex = cex) text(x, 0.3, "(a) 仿宋 测试字体Times New Roman FangSong", family = "fsong", cex = cex) text(x, 0.2, "(a) 测试字体 Times", family = "Times", cex = cex) text(x, 0.1, "(a) 测试字体 rTimes", family = "rTimes", cex = cex, font = 2) text(x, 0, "(a) 测试字体 TimesSimSun", family = "TimesSimSun", cex = cex, font = 2) }, "a.pdf", 10, 6) # `Times` also works for Linux system # clear_font()
write_fig({ par(family = "TimesSimSun", cex = 1.4) plot(0, main = "测试字体 Times New Roman") plot(0, main = "测试字体 Times New Roman") }, "TimesSimSun.pdf", 10, 6)
# 1. jpg, tif:对于中文可以自动设置宋体 # 2. emf 可以自动设置中文字体,但是不支持AI编辑 write_fig({ par(family = "Times", cex = 1.4) plot(0, main = "测试字体 Times New Roman") }, "a.jpg", 10, 6, devices = c("tif", "jpg", "png", "emf", "svg"))
library(ggplot2) ggplot(trees, aes(Girth, Height)) + geom_line() + theme(plot.title = element_text(family = "rTimes")) + labs(title = "测试字体 rTimes") -> p write_fig(p, 'Rplot.pdf', 10, 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.