最近老看见各种加了背景的柱状图,比如一下这样的好像是华尔街日报的
于是尝试了一下用Matplotlib做了一下
由于作者比较懒惰,y值就随机生成了
from matplotlib import pyplot as pltimport randomrandom.seed(33)y1=[random.randint(40,50) for i in range(5)]y2=[random.randint(30,40) for i in range(5)]y3=[random.randint(20,30) for i in range(5)]y4=[random.randint(10,20) for i in range(5)]y5=[random.randint(0,10) for i in range(5)]y6=[i for i in range(2011,2016)] x=[i*2-1 for i in range(1,6)]
其实思路很简单