指定绘图样式
matplotlib 库自带多种样式表,您可以用它们自定义图形外观。要为图形使用某个样式表,请使用命令 plt.style.use(your_stylesheet),其中 your_stylesheet 是样式表名称。
若要查看可用样式表列表,请使用命令 print(plt.style.available)。在本课程的其余部分,我们将使用非常好用的 fivethirtyeight 样式表。
本练习是课程的一部分
用 Python 可视化时间序列数据
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Import the matplotlib.pyplot sub-module
____
# Use the fivethirtyeight style
plt.____('fivethirtyeight')
# Plot the time series
ax1 = discoveries.plot()
ax1.set_title('FiveThirtyEight Style')
plt.show()