matplotlib学习笔记(4)—柱状图
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
plt.figure(figsize=(13, 5))
labels = ['2016', '2017', '2018', '2019', '2020']
first = [20, 34, 30, 35, 27]
second = [25, 32, 34, 20, 25]
third = [21, 31, 37, 21, 28]
fourth = [26, 31, 35, 27, 21]
five = [27, 37, 38, 24, 17]
plt.subplot()
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
x = np.arange(len(labels))
width = 0.1
plt.bar(x - 1.5*width, first, width, label='Landsat 7')
plt.bar(x - 0.5*width, second, width, label='Landsat 8')
plt.bar(x + 0.5*width, third, width, label='Sentinel-1')
plt.bar(x + 1.5*width, fourth, width, label='Sentinel-2')
plt.bar(x + 2.5*width, five, width, label='Aster')
plt.ylabel("影像景数")
plt.xticks(x, labels=labels)
plt.legend()
plt.show()