กราฟ
ต่อไปจะสร้างกราฟที่แสดงความล่าช้าในการออกเดินทางจำแนกตามสนามบินต้นทาง และค่าเฉลี่ยความล่าช้ารวมจำแนกตามสายการบิน
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Python สำหรับผู้ใช้ R
คำแนะนำการฝึกหัด
- สร้างรูปภาพที่มีสองแกน (2 แถว 1 คอลัมน์)
- ใช้ seaborn และ
flightsสร้าง boxplot โดยให้'origin'อยู่บนแกน x และ'dep_delay'อยู่บนแกน y - ใช้ seaborn และ
tdel_carสร้าง bar plot โดยให้'carrier'อยู่บนแกน x และ'total_delay'อยู่บนแกน y - ตั้งชื่อ boxplot ว่า 'Originating airport and the departure delay'
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Create a figure
fig, (ax1, ax2) = plt.subplots(____)
# Boxplot and barplot in the axes
sns.____(x=____, y=____, data=flights, ax=____)
sns.____(x=____, y=____, data=tdel_car, ax=____)
# Label axes
ax1.set_title(____)
# Use tight_layout() so the plots don't overlap
fig.tight_layout()
plt.show()