'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>文件: 双层直方图.py
>>作者: liu yang
>>邮箱: liuyang0001@outlook.com
>>博客: www.cnblogs.com/liu66blog ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' #!/usr/bin/env python
# -*- coding: utf-8 -*-
import matplotlib
import matplotlib.pyplot as plt
# 指定字体,防止
font=matplotlib.font_manager.FontProperties(fname=r"C:\Windows\Fonts\Deng.ttf") # 双层直方图
def barsplot():
# 先生成一个画布
fig=plt.figure()
# 生成数据
x1=[x-0.2 for x in range(1,9)]
y1=[n*2 for n in range(1,9)]
x2=[x+0.2 for x in range(1,9)]
y2=[x**2 for x in x2]
# 开始画条形图1
l1=plt.bar(x1,y1,color='g',width=0.4)
# 开始画条形图2
l2=plt.bar(x2,y2,color='b',width=0.4)
# 显示画的图
plt.xlabel('x轴信息',fontproperties=font)
plt.ylabel('y轴信息',fontproperties=font)
plt.title('双层直方图',fontproperties=font)
plt.legend(handles = [l1, l2,], labels = ['去年', '今年'], loc = 'best',prop=font)
for x1,x2, y1, y2 in zip(x1,x2, y1, y2):
plt.text(x1 , y1, '%.0f' % y1, ha='center', va='bottom')
plt.text(x2 , y2, '%.0f' % y2, ha='center', va='bottom')
plt.show() # 如果最为主模块运行
if __name__ == '__main__':
# 实例化
ba=barsplot()

[Python Study Notes]双层柱状图绘制的更多相关文章

  1. [Python Study Notes]堆叠柱状图绘制

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  2. [Python Study Notes]水平柱状图绘制

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  3. [Python Study Notes]气泡散点图绘制

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  4. [Python Study Notes]七彩散点图绘制

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  5. [Python Study Notes]折线图绘制

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  6. [Python Study Notes]饼状图绘制

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  7. [Python Study Notes]匿名函数

    Python 使用 lambda 来创建匿名函数. lambda这个名称来自于LISP,而LISP则是从lambda calculus(一种符号逻辑形式)取这个名称的.在Python中,lambda作 ...

  8. [Python Study Notes]字符串处理技巧(持续更新)

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  9. [Python Study Notes]with的使用

    在 Python 2.5 中, with 关键字被加入.它将常用的 try ... except ... finally ... 模式很方便的被复用.看一个最经典的例子: with open('fil ...

随机推荐

  1. 《RocketMQ 安装和使用》

    安装Maven 安装步骤:<Maven的安装.配置及使用入门> http://www.cnblogs.com/dcba1112/archive/2011/05/01/2033805.htm ...

  2. 【转】Pearson,Spearman,Kendall相关系数的具体分析

    测量相关程度的相关系数很多,各种参数的计算方法及特点各异. 连续变量的相关指标: 此时一般用积差相关系数,又称pearson相关系数来表示其相关性的大小,积差相关系数只适用于两变量呈线性相关时.其数值 ...

  3. ControlTemplate,ItemsPanelTemplate,DataTemplate(wpf)

    在WPF中有三大模板ControlTemplate,ItemsPanelTemplate,DataTemplate.其中ControlTemplate和ItemsPanelTemplate是控件模板, ...

  4. Difference between menu item types; Display, Output and Action in Dynamics Ax

    Difference between menu item types; Display, Output and Action in Dynamics Ax Developers often ask m ...

  5. javascript中some,every,map,filter是只用和ansyc中的each,eachLimit,map,mapLImit,filter的使用

    var t = [1,2,3,4,5]; //some找到数组中第一个符合要求的值后就不在继续执行//用来判断数组中是否存符合要求的值,返回结果true|false//function返回类型为boo ...

  6. Oracle Index Clustering Factor(集群因子)

    一.本文说明: 今天在做测试的时候发现字段上有索引,但是执行计划就是不走索引,经过在网上查找才发现原来是索引的集群因子过高导致的.本文属于转载 二.官网说明 The index clustering ...

  7. PageRank算法原理及实现

    PageRank算法原理介绍 PageRank算法是google的网页排序算法,在<The Top Ten Algorithms in Data Mining>一书中第6章有介绍.大致原理 ...

  8. JSDoc 介绍

    什么是JSDoc JSDoc是一个根据javascript文件中注释信息,生成JavaScript应用程序或库.模块的API文档 的工具.你可以使用他记录如:命名空间,类,方法,方法参数等.类似Jav ...

  9. mysql之 mysql 5.6不停机主从搭建(一主一从基于日志点复制)

    环境说明:版本 version 5.6.25-log 主库ip: 10.219.24.25从库ip:10.219.24.22os 版本: centos 6.7已安装热备软件:xtrabackup 防火 ...

  10. Kerberos的启动和关闭

    Kerberos概念 1.Kerberos用户 Kerberos的本质是维护一套自己的用户:或者说是核心用户映射,比如你的系统用户里面有hdfs,那么我将会在KDC中创建一套基于机器(假设我们有三台安 ...