我在我的mac上使用ggplot2创建了一个绘图.我将字体更改为Times New Roman,效果很好.
library(extrafont) ggplot(data=df)+ stat_density(aes(x=R1, colour="rho = -0,6"), adjust=4, lwd=0.65, geom="line", position="identity")+ stat_density(aes(x=R2, colour="rho = 0,6"), adjust=4, lwd=0.65, geom="line", position="identity")+ stat_density(aes(x=R3, colour="rho = 0"), adjust=4, lwd=0.65, linetype=2, geom="line", position="identity")+ xlim(-1, 1)+ xlab("Renditen")+ ylab("Dichte")+ ggtitle("Renditeverteilung im Heston-Modell")+ theme(plot.title=element_text(face="bold", size=16, vjust=2, family="Times New Roman"), axis.title.x=element_text(vjust=-1, size=14, family="Times New Roman"), axis.title.y=element_text(vjust=-0.25, size=14, family="Times New Roman"), legend.text=element_text(size=14, family="Times New Roman"), legend.title=element_blank(), legend.margin=unit(1, "cm"), legend.key.line"), legend.key.size=unit(0.8, "cm"), legend.key=element_rect(fill=NA), legend.background=element_blank(), plot.margin=unit(c(1,1,1,1), "cm"))+ scale_colour_manual(values=c("red","black", "blue"), labels=greeks_rho)+ guides(colour=guide_legend(override.aes=list(linetype=c(1,3,1))))
这是Mac上的结果:
我需要以WMF格式导出绘图,所以我在Windows上使用R Studio,我无法将字体更改为Times New Roman.除了上面的代码之外我还做了以下代码而没有成功.
library(extrafont) font_import() loadfonts()
我得到这样的警告(英文:〜"在Windows字体数据库中找不到字体系列")
47: In grid.Call.graphics(L_text, as.graphicsAnnot(x$label), ... : Zeichensatzfamilie in der Windows Zeichensatzdatenbank nicht gefunden
这是Windows上的结果:
并且:为什么Mac上的图形线看起来比在Windows上要平滑得多?
有人可以帮忙吗?谢谢!