可视化航空公司数据集
现在请回顾第 1 章的内容。您将有机会使用一个新数据集,其中包含 1949 年 1 月至 1960 年 12 月期间每月搭乘商业航班的乘客人数。
我们已为您打印了 airline 数据框的前 5 行和后 5 行,供您查看。
本练习是课程的一部分
用 Python 可视化时间序列数据
练习说明
- 使用「蓝色」线图绘制
airline的时间序列。 - 在图上 1955 年 12 月 1 日处添加一条竖直线。
- 为图中的 x 轴设置标签:
'Date'。 - 为图设置标题:
'Number of Monthly Airline Passengers'。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Plot the time series in your DataFrame
ax = airline.____(____, fontsize=12)
# Add a red vertical line at the date 1955-12-01
____('1955-12-01', color='red', linestyle='--')
# Specify the labels in your plot
ax.____('Date', fontsize=12)
ax.____('Number of Monthly Airline Passengers', fontsize=12)
plt.show()