吴俊给的代码:
# 用 base R function 引入字体
windowsFonts(A=windowsFont("微软雅黑"))
# 绘图示意
plot(1:10, 1:10, type="n")
text(6,4,"微软雅黑", family="A")
实际操作:
首先在前部分代码运行
windowsFonts(A=windowsFont("微软雅黑"))
然后,在ggplot2中代码部分加上+theme_grey(base_family = "A")
ggplot(orders,aes(x=segment,y=quantity))+
geom_bar(stat='identity')+
facet_grid(type~market)+
scale_y_continuous(labels=y_axis_formatter)+
xlab("细分市场")+
ylab("数量")+theme_grey(base_family = "A")+
coord_flip()