在 R 中更改箱线图字体
Changing boxplot Fonts in R
我正在尝试通过 R 中的此命令将箱线图字体更改为“Times New Roman”:
library(extrafont)
loadfonts(device="win")
fonts()
boxplot(sp ~ grp, data = mydata,family="Times New Roman")
但是图中的字体没有变化。如何更改箱线图中的所有文本?
提前致谢
You can see the results here
试试这个:
windowsFonts(
A=windowsFont("Arial Black"),
B=windowsFont("Bookman Old Style"),
C=windowsFont("Comic Sans MS"),
D=windowsFont("Times New Roman")
)
par(mfrow=c(2,2))
for (f in LETTERS[1:4]) {
par(family=f)
boxplot(Sepal.Length ~ Species, data = iris, main = "Title", font=2)
}
无法通过在 boxplot()
中设置 family
来更改字体系列。相反,在调用 boxplot()
.
之前使用 par(family = "Times New Roman")
修改此图形参数
下面是一个可重现的例子:
boxplot(count ~ spray, data = InsectSprays)
boxplot(count ~ spray, data = InsectSprays, family = "serif")
# -> 'family' has no effect here
par(family = "serif")
boxplot(count ~ spray, data = InsectSprays)
# -> font has changed
我正在尝试通过 R 中的此命令将箱线图字体更改为“Times New Roman”:
library(extrafont)
loadfonts(device="win")
fonts()
boxplot(sp ~ grp, data = mydata,family="Times New Roman")
但是图中的字体没有变化。如何更改箱线图中的所有文本? 提前致谢 You can see the results here
试试这个:
windowsFonts(
A=windowsFont("Arial Black"),
B=windowsFont("Bookman Old Style"),
C=windowsFont("Comic Sans MS"),
D=windowsFont("Times New Roman")
)
par(mfrow=c(2,2))
for (f in LETTERS[1:4]) {
par(family=f)
boxplot(Sepal.Length ~ Species, data = iris, main = "Title", font=2)
}
无法通过在 boxplot()
中设置 family
来更改字体系列。相反,在调用 boxplot()
.
par(family = "Times New Roman")
修改此图形参数
下面是一个可重现的例子:
boxplot(count ~ spray, data = InsectSprays)
boxplot(count ~ spray, data = InsectSprays, family = "serif")
# -> 'family' has no effect here
par(family = "serif")
boxplot(count ~ spray, data = InsectSprays)
# -> font has changed