始める無料で始める

グラフの作成

出発地別の出発遅延と、航空会社別の平均総遅延時間を可視化する図を作成しましょう。

この演習はコースの一部です

R ユーザーのための Python

コースを見る

演習の手順

  • 2つの軸(2行1列)を持つ図を作成してください。
  • seaborn と flights を使って、x 軸に 'origin'、y 軸に 'dep_delay' を指定した箱ひげ図を作成してください。
  • seaborn と tdel_car を使って、x 軸に 'carrier'、y 軸に '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()
コードを編集して実行