整理饼图
上一题中您做的饼图不错,但有些杂乱。让我们用 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.
___ +
___