import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['font.sans-serif'] = 'simhei'
plt.rcParams['axes.unicode_minus']=False
y2019 = [2043,1256,860,1211,1807,2207,2007,2107]
y2020 = [2143,1856,1060,1011,1407,2407,2207,2307]
y = np.arange(len(y2019))
month = ['{}月'.format(i) for i in range(1,9)]
height=0.3
plt.barh(y,y2019,height=height,label='2019年')
plt.barh(y+0.3,y2020,height=height,label='2020年')
plt.yticks(y+1/2*height,month)
plt.title("D02车次上车人数")
plt.legend()
plt.show()
效果图如下: