Python中使用matplotlib函数画折线图,具体方法如下:
import numpy as np #导入numpy模块
import matplotlib.pyplot as plt #导入matplotlib模块
x = np.linspace(0, 2 * np.pi, 100)
y1, y2 = np.sin(x), np.cos(x)
plt.plot(x, y1)
plt.plot(x, y2)
plt.title('line chart')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
效果图: