CommencerCommencer gratuitement

Plots

You will now create a figure in which you can visualize the departure delay by origin and the average total delay by carrier.

Cet exercice fait partie du cours

Python for R Users

Afficher le cours

Instructions

  • Create a figure with two axes (2 rows and 1 column).
  • Use seaborn and flights to create a boxplot of 'origin' and 'dep_delay' on x and y axes, respectively.
  • Use seaborn and tdel_car to create a bar plot of 'carrier' and 'total_delay' on x and y axes, respectively.
  • Label the boxplot: 'Originating airport and the departure delay'.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# 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()
Modifier et exécuter le code