python柱状图篇 中文显示、数字标注
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 23 22:33:11 2020
@author: del
"""
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.style.use('classic');
myfont=mpl.font_manager.FontProperties(fname='simhei.ttf');#从电脑的字体文件夹复制这个字体到当前文件夹
numlist =[3,4,5];
numlist1=[6,7,8];
labels=['First','Second','Third'];#柱子的标签
#这个中文不能显示,可以用ppt加上,我就是这么干的
width=0.3;#柱子的宽度
index=np.arange(len(labels));
plt.bar(index,numlist,width,tick_label=labels,color='steelblue'