1. Learn
  2. /
  3. คอร์ส
  4. /
  5. การแสดงผลข้อมูลด้วย ggplot2 เบื้องต้น

Connected

แบบฝึกหัด

Bar plots: ชุดสีแบบลำดับ (sequential color palette)

ใน bar plot นี้ เราจะกำหนดสีให้แต่ละส่วนตามตัวแปรแบบ ordinal วิธีที่เหมาะสมที่สุดคือการใช้ชุดสีแบบลำดับ (sequential color palette)

นี่คือตัวอย่างการใช้ sequential color palette กับชุดข้อมูล mtcars:

ggplot(mtcars, aes(fcyl, fill = fam)) +
  geom_bar() +
  scale_fill_brewer(palette = "Set1")

ในแบบฝึกหัดนี้ จะใช้โค้ดในลักษณะเดียวกันกับชุดข้อมูล Vocab โดยข้อมูลทั้งสองชุดเป็นข้อมูลแบบ ordinal

คำแนะนำ 1/3

undefined XP
    1
    2
    3
  • สร้างกราฟจากชุดข้อมูล Vocab โดย map education ไปที่ x และ vocabulary ไปที่ fill