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

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

一、双柱状图效果图

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

 二、双柱状图实现代码
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

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/798246.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-06
下一篇 2022-05-06

发表评论

登录后才能评论

评论列表(0条)

保存