開始使用免費開始

繪圖

你現在要建立一個圖表,用來視覺化各出發機場的起飛延誤,以及各家航空公司的平均總延誤。

本練習屬於課程

給 R 使用者的 Python

檢視課程

練習說明

  • 建立一個包含 2 個座標軸的圖表(2 列、1 欄)。
  • 使用 seaborn 與 flights,在 x 與 y 軸上分別以 'origin''dep_delay' 繪製箱形圖。
  • 使用 seaborn 與 tdel_car,在 x 與 y 軸上分別以 'carrier''total_delay' 繪製長條圖。
  • 將箱形圖標示為:'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()
編輯並執行程式碼