本文实例讲述了Python实现绘制双柱状图并显示数值功能。分享给大家供大家参考,具体如下:
# -*- coding:utf-8 -*-
#! python3
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d
#定义函数来显示柱状上的数值
def autolabel(rects):
for rect in rects:
height = rect.get_height()
plt.text(rect.get_x()+rect.get_width()/2.-0.2, 1.03*height, '%s' % floa
1