我将晶格图的字体更改为LM Modern 10,并将其包含在个性化主题中。还可以在主题中包括图例的字体样式吗?如果没有,是否可以在key参数中更改字体样式?
谢谢, 玛拉
代码示例:
mytheme<-list()
mytheme$par.xlab.text$fontfamily="LM Roman 10"
my.key <- list(
space="bottom",
columns=3,
lines=list(pch=c(19,1,15), size = 7,type=c("p")),
text = list(c("text1", "text2", "text3")))
xyplot(data=dataframe,
d1~d2,
par.settings=mytheme,
key=my.key)
答案 0 :(得分:0)
我认为可能会完成...试试这个:
使用extraFonts加载字体集。在此示例中,我将使用旧标准字体(https://fonts.google.com/specimen/Old+Standard+TT?selection.family=Old+Standard+TT),因为找不到LM Roman的真实类型。
# do once!
library(extrafont)
font_import(pattern = "Old*", path =
"C:/Downloads/Old_Standard_TT")
下一步加载字体(每次使用extraFont执行)
library(extrafont)
loadfonts(device = "win")
更改晶格中的参数设置:
`
library(lattice)
dataframe <- data.frame(d1 = rnorm(100), d2 = rnorm(100))
font.settings <- list(
font = 1,
cex = 1,
fontfamily = "Old Standard TT")
my.theme <- list(
par.xlab.text = font.settings,
par.ylab.text = font.settings,
axis.text = font.settings,
sub.text = font.settings,
add.text = font.settings)
my.key <- list(
space="bottom",
columns=3,
lines=list(pch=c(19,1,15), size = 7,type=c("p")),
text = list(c("text1", "text2", "text3")),
fontfamily = "Old Standard TT")
xyplot(data=dataframe,
d1~d2,
par.settings=my.theme,
key=my.key)
`
https://r.789695.n4.nabble.com/color-and-fontfamily-in-lattice-td877556.html
How can I make an R plot use the Latin Modern font family when saved as a PDF?