Plots
You will now create a figure in which you can visualize the departure delay by origin and the average total delay by carrier.
This exercise is part of the course
Python for R Users
Exercise 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'.
Hands-on interactive exercise
Have a go at this exercise by completing this sample 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()