surgのブログ

日々のネタ忘備録。勉強用。R初心者。切ったり縫ったりする人。

Bar chartのannotationはgeom_text()か、ggtext::geom_bar_text()か

どっちがいいかはまあお好みですかね。仕上がりを見て。

hoge %>% 
  ggplot(aes(x=huga, y=proportion, label=percent)) +
  geom_bar(stat = "identity", fill="blue") + 
  ggfittext::geom_bar_text(fontface='bold', size=14)

もしくは

hoge %>% 
  ggplot(aes(x=huga, y=proportion, label=percent)) +
  geom_bar(stat = "identity", fill="blue") + 
  geom_text(hjust=-0.1, fontface="bold", size=5)