Python画柱状图(双柱状图,三柱状图)且显示对应数值

一、双柱状图效果图

使用python实现双柱状图,并且在柱状图形的顶部显示对应数值;

Python画柱状图(双柱状图,三柱状图)且显示对应数值_第1张图片

 二、双柱状图实现代码

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from pylab import mpl
mpl.rcParams['font.sans-serif']=['KaiTi']
mpl.rcParams['font.serif']=['KaiTi']

df=pd.read_csv('data.csv',index_col=0,encoding='gbk')
df.plot(kind='bar',width=0.4)

labels = ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]
men_means = df["蒸发量"].values.tolist()
women_means = df["降水量"].values.tolist()

x = np.arange(len(labels))  # the label locations
width = 0.4  # the width of the bars

fig, ax = pl

你可能感兴趣的:(Java,python)