ปรับ viewport เพื่อไม่ให้ป้ายกำกับทับกับขอบพล็อต
ใช้ฟังก์ชันที่แนะนำในวิดีโอก่อนหน้าเพื่อปรับ viewport ของพื้นที่พล็อต และนำ custom theme ที่สร้างไว้มาใช้ด้วย
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การสื่อสารด้วยข้อมูลใน Tidyverse
คำแนะนำการฝึกหัด
- แก้ปัญหาป้ายกำกับทับซ้อนกัน โดยรีเซ็ตขอบเขตแกน x ของระบบพิกัดคาร์ทีเซียนให้เป็น
25และ41ให้แน่ใจว่าใช้ฟังก์ชันที่ไม่ตัด geometry ในพล็อตออก - ยังจำฟังก์ชัน
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