金魚亭日常

読書,ガジェット,競技プログラミング

ggplot2で日本語軸ラベルのやつ(RStudio)

if (.Platform$OS.type == "windows"){
  windowsFonts(msgothic = windowsFont("MSGothic"))
  jpfont <- element_text(family = "msgothic")
} else if (Sys.info()["sysname"] == "Darwin") {
  jpfont <- element_text(family = "HiraKakuPro-W3")
} else {
  jpfont <- element_text(family = "IPAexGothic")
}

d %>% 
  ggplot(aes(x = x, y = y)) + 
    geom_points() + 
    theme(
      axis.title = jpfont
    )