install.packages("extrafont")
library(extrafont)
font_import()
按一下y,然后回车
这个时间很长。要耐心。。。。
fonts() 或者
fonttable()
pdf("plot_garamond.pdf", family="Garamond", width=4, height=4.5)
plot(mtcars$mpg, mtcars$wt,
main = "Fuel Efficiency of 32 Cars",
xlab = "Weight (x1000 lb)",
ylab = "Miles per Gallon")
dev.off()
library(ggplot2)
p <- ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() +
ggtitle("Fuel Efficiency of 32 Cars") +
xlab("Weight (x1000 lb)") + ylab("Miles per Gallon") +
theme_bw() +
theme(text=element_text(family="Garamond", size=14))
ggsave("ggplot_garamond.pdf", p, width=3.5, height=3.5)