开始使用免费开始使用

绘图

现在请创建一个图形,用于可视化不同始发机场的起飞延误,以及不同承运人的平均总延误。

本练习是课程的一部分

面向 R 用户的 Python

查看课程

练习说明

  • 创建一个包含两个坐标轴的图形(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()
编辑并运行代码