01
美元/人民币汇率走势
对比 2017 与 2019 年 7 月的汇率变化,练习颜色、线型与线宽设置。
查看 Python 代码 +
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["font.sans-serif"] = ["SimHei"]
plt.rcParams["axes.unicode_minus"] = False
eurcny_2017 = np.array([6.8007,6.8060,6.7835,6.7700,6.7511,6.7265])
eurcny_2019 = np.array([6.8640,6.8881,6.8662,6.8827,6.8737,6.8841])
date_x = np.array([3,8,13,17,25,31])
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(date_x, eurcny_2017, color='g',linestyle='-.',linewidth=1, label='2017年7月美元/人民币汇率')
ax.plot(date_x, eurcny_2019, color=(0.8, 0.2, 0.4), linestyle='--', linewidth=3, label='2019年7月美元/人民币汇率')
ax.set_title('2017年7月与2019年7月美元/人民币汇率走势')
ax.set_xlabel('日期')
ax.set_ylabel('汇率')
ax.legend()
plt.show()
