【问题标题】:How to change font type of plots in R?如何更改 R 中绘图的字体类型?
【发布时间】:2019-11-17 20:24:42
【问题描述】:

我有一个 R 语言脚本的饼图。我想要 Times New Roman 字体中的传说和数字,但尽管我在 google 中看到了很多解决方案,但它们都不起作用。我的代码如下:

library("readr")
library("fmsb")
library("car")
library("normtest")
library("nortest")
library("moments")
library("readxl")  
library("ggplot2")
library("stats")
library("lsr")

categorias <-c("Básica",
              "Media",
              "Superior (IP o CFT)",
              "Superior universitaria",
              "Postrado")
contar <-c(10,
          27,
          15,
          16,
          1)
par(family="Times New Roman")
piepercent<- round(100*contar/sum(contar), 2)
lbls <- paste(piepercent) # add percents to labels
lbls <- paste(lbls,"%",sep="")
png(file="NIVEL_EDUCACIONAL.eps")
pie(contar, radius=1.0,labels = lbls,col = rainbow(length(contar)))
legend("topleft",categorias, cex = 0.9, fill = rainbow(length(contar)))
dev.off()

有什么想法吗?在此先感谢和问候:D

【问题讨论】:

    标签: r plot pie-chart


    【解决方案1】:

    Times New Roman 通常是默认的衬线字体。使用windowsFonts() 进行验证。然后调用默认字体而不是具体字体:

    par(family = 'serif')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多