import matplotlib.pyplot as plt
import numpy as np
plt.title("y=cos(x)") # 添加图片标题
x = np.arange(0, 10, 1)
plt.plot(x, x, 'r-.', x, np.cos(x), 'g--', marker='*')
plt.legend(["red", "green"], loc='lower right') # loc='upper left'
plt.show()
参考书目《Python数据可视化之matplotlib实践》