円グラフを見やすくする
前の演習で作成した円グラフは良いのですが、少しごちゃついています。ggplot の theme_void() を使って見た目を整え、ggtitle(...) で意味のあるタイトルを付けましょう。
前の演習で作成した集計済みデータフレーム disease_counts は、すでに読み込まれています。
この演習はコースの一部です
R による可視化ベストプラクティス
演習の手順
- 背景をすっきりさせるために、ggplot オブジェクトに
theme_void()を追加します。 - プロットのタイトルを
'Proportion of diseases'とします。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
ggplot(disease_counts, aes(x = 1, y = total_cases, fill = disease)) +
# Use a column geometry.
geom_col() +
# Change coordinate system to polar.
coord_polar(theta = "y") +
# Clean up the background with theme_void and give it a proper title with ggtitle.
___ +
___