【发布时间】:2013-12-28 01:56:07
【问题描述】:
我在我的 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.height=unit(1, "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()
我收到这样的警告(英文:~“Font Family not found in Windows Font Database”)
47: In grid.Call.graphics(L_text, as.graphicsAnnot(x$label), ... :
Zeichensatzfamilie in der Windows Zeichensatzdatenbank nicht gefunden
这是在 Windows 上的结果:
还有:为什么图表的线条在 Mac 上看起来比在 Windows 上平滑很多?
有人可以帮忙吗?谢谢!
【问题讨论】: