【发布时间】:2017-01-03 17:36:19
【问题描述】:
我有一个使用基本图形包的图表。对于特定点上的标签,我使用
text(i, MSSAcar$summary[i,7]+.7, qld$LGA[i],
col='red', cex=.7, family='serif')
我还在主标题和轴标签的情节中使用了它。它们都按预期出现。
当我添加图例时,我似乎无法设置字体系列。
谁能帮帮我。
谢谢。
【问题讨论】:
我有一个使用基本图形包的图表。对于特定点上的标签,我使用
text(i, MSSAcar$summary[i,7]+.7, qld$LGA[i],
col='red', cex=.7, family='serif')
我还在主标题和轴标签的情节中使用了它。它们都按预期出现。
当我添加图例时,我似乎无法设置字体系列。
谁能帮帮我。
谢谢。
【问题讨论】:
在调用legend() 之前将family 绘图参数设置为所需的值。通过显式调用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("topright", legend = "foo legend", pch = 1, bty = "n")
## reset plotting parameters
par(op)
真的,您可以在第一次调用plot() 之前更改family,并在调用text() 时省略family = "serif" 参数。通过par() 设置对于当前设备是全局的,在函数调用中使用参数对于该调用是本地的。
上面的代码产生:
【讨论】: