3.13. フォントを指定
標題とグラフの軸目盛に別々のフォントを指定します。
windowsFonts(HGKAI=windowsFont("HG正楷書体-PRO")) windowsFonts(COURIER=windowsFont("Courier New")) # ggplot2 パッケージを使用 library(ggplot2) # ヒストグラムを描画 g <- ggplot(d) g <- g + geom_histogram( aes( x=d$"自チーム.10分あたりのTOUCH数", y=..density.., colour= d$"勝敗", fill=d$"勝敗" ), binwidth=5, alpha=0.3, position="identity" ) # タイトルを変更 g <- g + labs(title="10分あたりのボールタッチ回数") g <- g + xlab("ボールタッチ") g <- g + ylab("確率密度") g <- g + labs(colour="凡例", fill="凡例") # フォントを指定 g <- g + theme_bw( base_size=12, base_family="HGKAI" ) g <- g + theme( plot.title=element_text(hjust=0.5), axis.text=element_text(family="COURIER", size=10) ) # 色を指定 g <- g + scale_color_manual(values=c(GREEN_5, BLUE_5, PINK_5)) g <- g + scale_fill_manual( values=c(GREEN_5, BLUE_5, PINK_5)) print(g)