使用python绘制折线图过程
1、导入库和设置输入折线图数据import numpy as np
import matplotlib.pyplot as plt
# x轴刻度标签
x_ticks = ['a', 'b', 'c', 'd', 'e', 'f']
# x轴范围(0, 1, ..., len(x_ticks)-1)
x = np.arange(len(x_ticks))
# 第1条折线数据
y1 = [5, 3, 2, 4, 1, 6]
# 第2条折线数据
y2 = [3, 1, 6, 5, 2, 4]
2、设置画布大小并绘制折线plt.figure(figsize=(10, 6))
# 画第1条折线,参数看名字就懂,还可以自定义数据点样式等等。
plt.plot(x, y1, color='#FF0000', label='label1', linewidth=3.0)
# 画第2条折线
plt.plot(x, y2, color='#00FF00', label='label2', linewidth=3.0)
# 给第1条折线数据点加上数值,前两个参数是坐标,第三个是数值,h