清理圓餅圖
你在上一張圖做的圓餅圖不錯,但有點雜亂。讓我們用 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.
___ +
___