在做毕设的过程中有些数据用表格来展现,会很难看出数据之间的差别,凸显不出数据的特点,所以想制作一个条形图,这里特地记录下,已备以后用到,这两张图对我这种小菜鸟来说可是花了一天的时间啊。。。。
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
#指定默认字体
matplotlib.rcParams['font.sans-serif'] = ['FangSong']
matplotlib.rcParams['font.family']='sans-serif'
c101= (8,7,3,7,10,4,11,8,11,10,8,9)
c102= (21,21,24,25,16,17,11,24,24,25,36,33)
c103= (4,4,10,3,9,8,12,2,4,5,2,6)
c104= (1,5,1,3,2,3,3,3,6,5,1,0)
c105= (3,1,0,1,3,3,1,2,0,0,0,0)
c106= (1,2,0,0,1,1,0,0,1,1,0,0)
c107= (1,0,1,0,0,1,0,0,0,0,0,0)
c108= (0,1,0,0,0,2,1,1,0,1,0,0)
c109= (1,0,1,1,0,0,1,1,0,0,0,0)
ind = np.arange(0,24,2) # the x locations for the groups
width = 0.2 # the width of the bars
fig,ax = plt.subplots()
rects1 = ax.bar(ind + width, c101, width, color='SkyBlue',align='edge', label='101')
rects2 = ax.b