import matplotlib
import matplotlib.pyplot as plt
myfont = matplotlib.font_manager.FontProperties(
fname='C:\Windows\Fonts\msyh.ttc')
matplotlib.rc('font', family='FangSong', weight='bold')
name_list = ['北京', '上海', '广州', '深圳', '成都']
data_list = [5, 4, 3, 2, 1]
colors = ['red', 'blue', 'green', 'yellow', 'gray']
plt.bar(range(len(data_list)), data_list,
color=colors, tick_label=name_list)
plt.title("一个简单的柱状图", fontsize=30, fontproperties=myfont)
plt.xlabel("横坐标", fontproperties=myfont)
plt.ylabel("纵坐标", fontproperties=myfont)
plt.show()
输出结果如图: