如何在此R图中更改字体系列? [英] How to change font family in this R plot?
本文介绍了如何在此R图中更改字体系列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将axis和legend的字体更改为衬线,但是添加family='serif'
不适用于图例.我该怎么办?
I am trying to change the font of axis and legend to serif but adding family='serif'
did not work for the legend. How should I do it?
plot(sort(n.cdf),pch=3,cex = 0.5,xlab="Order",ylab="Cn",family="serif")
par(new=TRUE)
plot(sort(emp.c),col="red",pch=1,cex = 0.5,ann=FALSE, axes=FALSE)
par(new=TRUE)
legend( "topleft"
, inset = c(0,0.1)
, cex = 1
, bty = "n"
, legend = c("Simulated", "Empirical")
, text.col = c("black", "red")
, pt.bg = c("black", "red")
, pch = c(3,1)
, family=c("serif")
)
推荐答案
在将legend()
调用为所需值之前,先设置family
绘图参数.通过显式调用par()
来做到这一点.
Set the family
plotting parameter before calling legend()
to the value you want. Do this via an explicit call to par()
.
这里是一个例子:
x <- y <- 1:10
plot(x, y, type = "n")
text(x = 5, y = 5, labels = "foo", family = "serif")
## set the font family to "serif"
## saving defaults in `op`
op <- par(family = "serif")
## plot legend as usual
legend( ... )
## reset plotting parameters
par(op)
这篇关于如何在此R图中更改字体系列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文