调整视口以避免标签与图形边框重叠
使用上一节视频介绍的函数来调整绘图区域的视口。同时应用您的自定义主题。
本练习是课程的一部分
在 Tidyverse 中用数据进行沟通
练习说明
- 通过将笛卡尔坐标系的 x 轴范围重设为
25和41来解决标签重叠问题。请确保使用不会裁剪图形几何对象的函数。 - 还记得自定义的
theme_ilo()函数吗?将它应用到该图。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Reuse ilo_dot_plot
ilo_dot_plot <- ilo_dot_plot +
# Add labels to the plot
labs(
x = "Working hours per week",
y = "Country",
title = "People work less in 2006 compared to 1996",
subtitle = "Working hours in European countries, development since 1996",
caption = "Data source: ILO, 2017"
) +
# Apply your theme
___ +
# Change the viewport
___(___ = c(___, ___))
# View the plot
ilo_dot_plot