简体   繁体   English

ggplot中的CM罗马字体

[英]CM Roman font in ggplot

For I can't use CM roman in ggplot.因为我不能在 ggplot 中使用 CM roman。

This works:这有效:

a <- ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() +
  ggtitle("Fuel Efficiency of 32 Cars") +
  xlab("Weight (x1000 lb)") + ylab("Miles per Gallon") +
  theme(text=element_text(size=16,  family="Times New Roman"))
print(a)

but this does not但这并不

a <- ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() +
  ggtitle("Fuel Efficiency of 32 Cars") +
  xlab("Weight (x1000 lb)") + ylab("Miles per Gallon") +
  theme(text=element_text(size=16,  family="CM Roman"))
print(a)

When I run fonts() it tells me that CM Roman is one of the fonts.当我运行fonts()时,它告诉我 CM Roman 是 fonts 之一。

the font probably isn't registered yet.该字体可能尚未注册。 run this first and try again:首先运行它,然后再试一次:

library(extrafont)
font_install('fontcm')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM