首页 > 解决方案 > 如何在r中更改图例的字体

问题描述

我想将图中标签和轴的字体更改为 Times New Roman 或 Times。 涂鸦博鲁塔

plot(boruta,  family = "Times", cex.lab = 1.0, xaxt = "n", horiz=1, las=1, xlab="Variables", ylab="Importancia")
legend(x = "topleft", legend = c("Importantes",  "Tentativas", "No importantes"), fill = c("green", "yellow",  "red"))

我已经尝试过这段代码,但它显然不会改变字母的字体。有人可以告诉我如何将图例字体和绘图轴更改为 Times New Roman 或 Times?

谢谢!

标签: r

解决方案


您需要在调用之前设置家庭legend

# Set the font family to "Times" and save defaults in `op`
op <- par(family = "serif")

推荐阅读